Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
76a715ee
Commit
76a715ee
authored
Jan 16, 2014
by
Hisham Muhammad
Browse files
Fix order of calloc arguments.
(Patch by Dawid Gajownik)
parent
c1e0f6e1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Affinity.c
View file @
76a715ee
...
...
@@ -20,9 +20,9 @@ typedef struct Affinity_ {
}*/
Affinity
*
Affinity_new
()
{
Affinity
*
this
=
calloc
(
sizeof
(
Affinity
)
,
1
);
Affinity
*
this
=
calloc
(
1
,
sizeof
(
Affinity
));
this
->
size
=
8
;
this
->
cpus
=
calloc
(
sizeof
(
int
),
this
->
size
);
this
->
cpus
=
calloc
(
this
->
size
,
sizeof
(
int
)
);
return
this
;
}
...
...
CPUMeter.c
View file @
76a715ee
...
...
@@ -152,7 +152,7 @@ static void AllCPUsMeter_getRange(Meter* this, int* start, int* count) {
static
void
AllCPUsMeter_init
(
Meter
*
this
)
{
int
cpus
=
this
->
pl
->
cpuCount
;
if
(
!
this
->
drawData
)
this
->
drawData
=
calloc
(
sizeof
(
Meter
*
)
,
cpus
);
this
->
drawData
=
calloc
(
cpus
,
sizeof
(
Meter
*
));
Meter
**
meters
=
(
Meter
**
)
this
->
drawData
;
int
start
,
count
;
AllCPUsMeter_getRange
(
this
,
&
start
,
&
count
);
...
...
Hashtable.c
View file @
76a715ee
...
...
@@ -76,7 +76,7 @@ Hashtable* Hashtable_new(int size, bool owner) {
this
=
(
Hashtable
*
)
malloc
(
sizeof
(
Hashtable
));
this
->
items
=
0
;
this
->
size
=
size
;
this
->
buckets
=
(
HashtableItem
**
)
calloc
(
sizeof
(
HashtableItem
*
)
,
size
);
this
->
buckets
=
(
HashtableItem
**
)
calloc
(
size
,
sizeof
(
HashtableItem
*
));
this
->
owner
=
owner
;
assert
(
Hashtable_isConsistent
(
this
));
return
this
;
...
...
Header.c
View file @
76a715ee
...
...
@@ -49,7 +49,7 @@ typedef struct Header_ {
#endif
Header
*
Header_new
(
ProcessList
*
pl
)
{
Header
*
this
=
calloc
(
sizeof
(
Header
)
,
1
);
Header
*
this
=
calloc
(
1
,
sizeof
(
Header
));
this
->
leftMeters
=
Vector_new
(
Class
(
Meter
),
true
,
DEFAULT_SIZE
);
this
->
rightMeters
=
Vector_new
(
Class
(
Meter
),
true
,
DEFAULT_SIZE
);
this
->
margin
=
true
;
...
...
IncSet.c
View file @
76a715ee
...
...
@@ -77,7 +77,7 @@ static inline void IncMode_done(IncMode* mode) {
}
IncSet
*
IncSet_new
(
FunctionBar
*
bar
)
{
IncSet
*
this
=
calloc
(
sizeof
(
IncSet
)
,
1
);
IncSet
*
this
=
calloc
(
1
,
sizeof
(
IncSet
));
IncMode_initSearch
(
&
(
this
->
modes
[
INC_SEARCH
]));
IncMode_initFilter
(
&
(
this
->
modes
[
INC_FILTER
]));
this
->
active
=
NULL
;
...
...
Meter.c
View file @
76a715ee
...
...
@@ -347,7 +347,7 @@ static const char* GraphMeterMode_characters = "^`'-.,_~'`-.,_~'`-.,_";
static
void
GraphMeterMode_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
if
(
!
this
->
drawData
)
this
->
drawData
=
calloc
(
sizeof
(
GraphData
)
,
1
);
if
(
!
this
->
drawData
)
this
->
drawData
=
calloc
(
1
,
sizeof
(
GraphData
));
GraphData
*
data
=
(
GraphData
*
)
this
->
drawData
;
const
int
nValues
=
METER_BUFFER_LEN
;
...
...
OpenFilesScreen.c
View file @
76a715ee
...
...
@@ -83,7 +83,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
char
command
[
1025
];
snprintf
(
command
,
1024
,
"lsof -P -p %d -F 2> /dev/null"
,
pid
);
FILE
*
fd
=
popen
(
command
,
"r"
);
OpenFiles_ProcessData
*
pdata
=
calloc
(
sizeof
(
OpenFiles_ProcessData
)
,
1
);
OpenFiles_ProcessData
*
pdata
=
calloc
(
1
,
sizeof
(
OpenFiles_ProcessData
));
OpenFiles_FileData
*
fdata
=
NULL
;
OpenFiles_ProcessData
*
item
=
pdata
;
bool
anyRead
=
false
;
...
...
@@ -104,7 +104,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
char
*
newline
=
strrchr
(
entry
,
'\n'
);
*
newline
=
'\0'
;
if
(
cmd
==
'f'
)
{
OpenFiles_FileData
*
nextFile
=
calloc
(
sizeof
(
OpenFiles_ProcessData
)
,
1
);
OpenFiles_FileData
*
nextFile
=
calloc
(
1
,
sizeof
(
OpenFiles_ProcessData
));
if
(
fdata
==
NULL
)
{
pdata
->
files
=
nextFile
;
}
else
{
...
...
Process.c
View file @
76a715ee
...
...
@@ -597,7 +597,7 @@ ObjectClass Process_class = {
};
Process
*
Process_new
(
struct
ProcessList_
*
pl
)
{
Process
*
this
=
calloc
(
sizeof
(
Process
)
,
1
);
Process
*
this
=
calloc
(
1
,
sizeof
(
Process
));
Object_setClass
(
this
,
Class
(
Process
));
this
->
pid
=
0
;
this
->
pl
=
pl
;
...
...
ProcessList.c
View file @
76a715ee
...
...
@@ -197,7 +197,7 @@ static ssize_t xread(int fd, void *buf, size_t count) {
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
)
{
ProcessList
*
this
;
this
=
calloc
(
sizeof
(
ProcessList
)
,
1
);
this
=
calloc
(
1
,
sizeof
(
ProcessList
));
this
->
processes
=
Vector_new
(
Class
(
Process
),
true
,
DEFAULT_SIZE
);
this
->
processTable
=
Hashtable_new
(
140
,
false
);
this
->
usersTable
=
usersTable
;
...
...
@@ -227,14 +227,14 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
this
->
topologyOk
=
true
;
}
#endif
this
->
cpus
=
calloc
(
sizeof
(
CPUData
)
,
cpus
);
this
->
cpus
=
calloc
(
cpus
,
sizeof
(
CPUData
));
for
(
int
i
=
0
;
i
<
cpus
;
i
++
)
{
this
->
cpus
[
i
].
totalTime
=
1
;
this
->
cpus
[
i
].
totalPeriod
=
1
;
}
this
->
fields
=
calloc
(
sizeof
(
ProcessField
),
LAST_PROCESSFIELD
+
1
);
this
->
fields
=
calloc
(
LAST_PROCESSFIELD
+
1
,
sizeof
(
ProcessField
)
);
// TODO: turn 'fields' into a Vector,
// (and ProcessFields into proper objects).
this
->
flags
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment