Fix order of calloc arguments.

(Patch by Dawid Gajownik)
This commit is contained in:
Hisham Muhammad 2014-01-16 18:51:16 -02:00
parent c1e0f6e17c
commit 76a715ee8c
9 changed files with 13 additions and 13 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;