diff --git a/Affinity.c b/Affinity.c index ce30aed3..3b1e311a 100644 --- a/Affinity.c +++ b/Affinity.c @@ -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; } diff --git a/CPUMeter.c b/CPUMeter.c index 77e7399b..ffbaea66 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -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); diff --git a/Hashtable.c b/Hashtable.c index 9d84db8a..0f61519e 100644 --- a/Hashtable.c +++ b/Hashtable.c @@ -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; diff --git a/Header.c b/Header.c index 7d954a3f..85a6aeee 100644 --- a/Header.c +++ b/Header.c @@ -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; diff --git a/IncSet.c b/IncSet.c index 2b9e052b..f38ba6dc 100644 --- a/IncSet.c +++ b/IncSet.c @@ -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; diff --git a/Meter.c b/Meter.c index 34238c86..cc2ac4a1 100644 --- a/Meter.c +++ b/Meter.c @@ -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; diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c index e33f2e76..ae511c83 100644 --- a/OpenFilesScreen.c +++ b/OpenFilesScreen.c @@ -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 { diff --git a/Process.c b/Process.c index 6765be7a..608ad4cc 100644 --- a/Process.c +++ b/Process.c @@ -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; diff --git a/ProcessList.c b/ProcessList.c index a0aed392..b470344c 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -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;