Commit 9791901b authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Fix sorting of OS-specific fields

parent 5fdfb3d8
Showing with 9 additions and 9 deletions
+9 -9
......@@ -27,7 +27,7 @@ typedef void(*Object_Delete)(Object*);
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));
#define AllocThis(class_) (class_*) xCalloc(sizeof(class_), 1); Object_setClass(this, Class(class_));
typedef struct ObjectClass_ {
const void* extends;
......
......@@ -28,7 +28,7 @@ typedef void(*Object_Delete)(Object*);
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));
#define AllocThis(class_) (class_*) xCalloc(sizeof(class_), 1); Object_setClass(this, Class(class_));
typedef struct ObjectClass_ {
const void* extends;
......
......@@ -108,7 +108,7 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
ProcessList_init(&this->super, Class(Process), usersTable, pidWhiteList, userId);
ProcessList_init(&this->super, Class(DarwinProcess), usersTable, pidWhiteList, userId);
/* Initialize the CPU information */
this->super.cpuCount = ProcessList_allocateCPULoadInfo(&this->prev_load);
......
......@@ -268,8 +268,7 @@ ObjectClass LinuxProcess_class = {
};
Process* Process_new(Settings* settings) {
LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess));
Object_setClass(this, Class(LinuxProcess));
LinuxProcess* this = AllocThis(LinuxProcess);
Process_init(&this->super, settings);
return (Process*) this;
}
......@@ -441,9 +440,9 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
case RBYTES: diff = p2->io_read_bytes - p1->io_read_bytes; goto test_diff;
case WBYTES: diff = p2->io_write_bytes - p1->io_write_bytes; goto test_diff;
case CNCLWB: diff = p2->io_cancelled_write_bytes - p1->io_cancelled_write_bytes; goto test_diff;
case IO_READ_RATE: diff = p2->io_rate_read_bps - p1->io_rate_read_bps; goto test_diff;
case IO_WRITE_RATE: diff = p2->io_rate_write_bps - p1->io_rate_write_bps; goto test_diff;
case IO_RATE: diff = (p2->io_rate_read_bps + p2->io_rate_write_bps) - (p1->io_rate_read_bps + p1->io_rate_write_bps); goto test_diff;
case IO_READ_RATE: return p2->io_rate_read_bps > p1->io_rate_read_bps ? 1 : -1;
case IO_WRITE_RATE: return p2->io_rate_write_bps > p1->io_rate_write_bps ? 1 : -1;
case IO_RATE: return (p2->io_rate_read_bps + p2->io_rate_write_bps) > (p1->io_rate_read_bps + p1->io_rate_write_bps) ? 1 : -1;
#endif
#ifdef HAVE_OPENVZ
case CTID:
......
......@@ -6,6 +6,7 @@ in the source distribution for its full text.
*/
#include "LinuxProcessList.h"
#include "LinuxProcess.h"
#include "CRT.h"
#include "StringUtils.h"
#include <errno.h>
......@@ -217,7 +218,7 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
LinuxProcessList* this = xCalloc(1, sizeof(LinuxProcessList));
ProcessList* pl = &(this->super);
ProcessList_init(pl, Class(Process), usersTable, pidWhiteList, userId);
ProcessList_init(pl, Class(LinuxProcess), usersTable, pidWhiteList, userId);
LinuxProcessList_initTtyDrivers(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment