mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-27 00:05:44 +00:00
Fix order of calloc arguments.
(Patch by Dawid Gajownik)
This commit is contained in:
parent
c1e0f6e17c
commit
76a715ee8c
@ -20,9 +20,9 @@ typedef struct Affinity_ {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
Affinity* Affinity_new() {
|
Affinity* Affinity_new() {
|
||||||
Affinity* this = calloc(sizeof(Affinity), 1);
|
Affinity* this = calloc(1, sizeof(Affinity));
|
||||||
this->size = 8;
|
this->size = 8;
|
||||||
this->cpus = calloc(sizeof(int), this->size);
|
this->cpus = calloc(this->size, sizeof(int));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ static void AllCPUsMeter_getRange(Meter* this, int* start, int* count) {
|
|||||||
static void AllCPUsMeter_init(Meter* this) {
|
static void AllCPUsMeter_init(Meter* this) {
|
||||||
int cpus = this->pl->cpuCount;
|
int cpus = this->pl->cpuCount;
|
||||||
if (!this->drawData)
|
if (!this->drawData)
|
||||||
this->drawData = calloc(sizeof(Meter*), cpus);
|
this->drawData = calloc(cpus, sizeof(Meter*));
|
||||||
Meter** meters = (Meter**) this->drawData;
|
Meter** meters = (Meter**) this->drawData;
|
||||||
int start, count;
|
int start, count;
|
||||||
AllCPUsMeter_getRange(this, &start, &count);
|
AllCPUsMeter_getRange(this, &start, &count);
|
||||||
|
@ -76,7 +76,7 @@ Hashtable* Hashtable_new(int size, bool owner) {
|
|||||||
this = (Hashtable*) malloc(sizeof(Hashtable));
|
this = (Hashtable*) malloc(sizeof(Hashtable));
|
||||||
this->items = 0;
|
this->items = 0;
|
||||||
this->size = size;
|
this->size = size;
|
||||||
this->buckets = (HashtableItem**) calloc(sizeof(HashtableItem*), size);
|
this->buckets = (HashtableItem**) calloc(size, sizeof(HashtableItem*));
|
||||||
this->owner = owner;
|
this->owner = owner;
|
||||||
assert(Hashtable_isConsistent(this));
|
assert(Hashtable_isConsistent(this));
|
||||||
return this;
|
return this;
|
||||||
|
2
Header.c
2
Header.c
@ -49,7 +49,7 @@ typedef struct Header_ {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Header* Header_new(ProcessList* pl) {
|
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->leftMeters = Vector_new(Class(Meter), true, DEFAULT_SIZE);
|
||||||
this->rightMeters = Vector_new(Class(Meter), true, DEFAULT_SIZE);
|
this->rightMeters = Vector_new(Class(Meter), true, DEFAULT_SIZE);
|
||||||
this->margin = true;
|
this->margin = true;
|
||||||
|
2
IncSet.c
2
IncSet.c
@ -77,7 +77,7 @@ static inline void IncMode_done(IncMode* mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IncSet* IncSet_new(FunctionBar* bar) {
|
IncSet* IncSet_new(FunctionBar* bar) {
|
||||||
IncSet* this = calloc(sizeof(IncSet), 1);
|
IncSet* this = calloc(1, sizeof(IncSet));
|
||||||
IncMode_initSearch(&(this->modes[INC_SEARCH]));
|
IncMode_initSearch(&(this->modes[INC_SEARCH]));
|
||||||
IncMode_initFilter(&(this->modes[INC_FILTER]));
|
IncMode_initFilter(&(this->modes[INC_FILTER]));
|
||||||
this->active = NULL;
|
this->active = NULL;
|
||||||
|
2
Meter.c
2
Meter.c
@ -347,7 +347,7 @@ static const char* GraphMeterMode_characters = "^`'-.,_~'`-.,_~'`-.,_";
|
|||||||
|
|
||||||
static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
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;
|
GraphData* data = (GraphData*) this->drawData;
|
||||||
const int nValues = METER_BUFFER_LEN;
|
const int nValues = METER_BUFFER_LEN;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
char command[1025];
|
char command[1025];
|
||||||
snprintf(command, 1024, "lsof -P -p %d -F 2> /dev/null", pid);
|
snprintf(command, 1024, "lsof -P -p %d -F 2> /dev/null", pid);
|
||||||
FILE* fd = popen(command, "r");
|
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_FileData* fdata = NULL;
|
||||||
OpenFiles_ProcessData* item = pdata;
|
OpenFiles_ProcessData* item = pdata;
|
||||||
bool anyRead = false;
|
bool anyRead = false;
|
||||||
@ -104,7 +104,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
char* newline = strrchr(entry, '\n');
|
char* newline = strrchr(entry, '\n');
|
||||||
*newline = '\0';
|
*newline = '\0';
|
||||||
if (cmd == 'f') {
|
if (cmd == 'f') {
|
||||||
OpenFiles_FileData* nextFile = calloc(sizeof(OpenFiles_ProcessData), 1);
|
OpenFiles_FileData* nextFile = calloc(1, sizeof(OpenFiles_ProcessData));
|
||||||
if (fdata == NULL) {
|
if (fdata == NULL) {
|
||||||
pdata->files = nextFile;
|
pdata->files = nextFile;
|
||||||
} else {
|
} else {
|
||||||
|
@ -597,7 +597,7 @@ ObjectClass Process_class = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Process* Process_new(struct ProcessList_ *pl) {
|
Process* Process_new(struct ProcessList_ *pl) {
|
||||||
Process* this = calloc(sizeof(Process), 1);
|
Process* this = calloc(1, sizeof(Process));
|
||||||
Object_setClass(this, Class(Process));
|
Object_setClass(this, Class(Process));
|
||||||
this->pid = 0;
|
this->pid = 0;
|
||||||
this->pl = pl;
|
this->pl = pl;
|
||||||
|
@ -197,7 +197,7 @@ static ssize_t xread(int fd, void *buf, size_t count) {
|
|||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
|
||||||
ProcessList* this;
|
ProcessList* this;
|
||||||
this = calloc(sizeof(ProcessList), 1);
|
this = calloc(1, sizeof(ProcessList));
|
||||||
this->processes = Vector_new(Class(Process), true, DEFAULT_SIZE);
|
this->processes = Vector_new(Class(Process), true, DEFAULT_SIZE);
|
||||||
this->processTable = Hashtable_new(140, false);
|
this->processTable = Hashtable_new(140, false);
|
||||||
this->usersTable = usersTable;
|
this->usersTable = usersTable;
|
||||||
@ -227,14 +227,14 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
|
|||||||
this->topologyOk = true;
|
this->topologyOk = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
this->cpus = calloc(sizeof(CPUData), cpus);
|
this->cpus = calloc(cpus, sizeof(CPUData));
|
||||||
|
|
||||||
for (int i = 0; i < cpus; i++) {
|
for (int i = 0; i < cpus; i++) {
|
||||||
this->cpus[i].totalTime = 1;
|
this->cpus[i].totalTime = 1;
|
||||||
this->cpus[i].totalPeriod = 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,
|
// TODO: turn 'fields' into a Vector,
|
||||||
// (and ProcessFields into proper objects).
|
// (and ProcessFields into proper objects).
|
||||||
this->flags = 0;
|
this->flags = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user