diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 2db1a924..ebbddf36 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -75,7 +75,7 @@ typedef enum LinuxProcessFields { OOM = 114, #endif IO_PRIORITY = 115, - LAST_PROCESSFIELD + LAST_PROCESSFIELD = 116, } LinuxProcessField; #include "IOPriority.h" diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 9770ab09..82ee0ef6 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -475,6 +475,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna } static bool LinuxProcessList_processEntries(LinuxProcessList* this, const char* dirname, Process* parent, double period, struct timeval tv) { + ProcessList* pl = (ProcessList*) this; DIR* dir; struct dirent* entry; Settings* settings = this->super.settings; @@ -551,7 +552,7 @@ static bool LinuxProcessList_processEntries(LinuxProcessList* this, const char* float percent_cpu = (lp->utime + lp->stime - lasttimes) / period * 100.0; proc->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0); if (isnan(proc->percent_cpu)) proc->percent_cpu = 0.0; - proc->percent_mem = (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0; + proc->percent_mem = (proc->m_resident * PAGE_SIZE_KB) / (double)(pl->totalMem) * 100.0; if(!existingProc) { @@ -633,7 +634,7 @@ static bool LinuxProcessList_processEntries(LinuxProcessList* this, const char* return true; } -static inline void LinuxProcessList_scanMemoryInfo(LinuxProcessList* this) { +static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) { unsigned long long int swapFree = 0; FILE* file = fopen(PROCMEMINFOFILE, "r"); @@ -754,7 +755,7 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) { void ProcessList_scan(ProcessList* super) { LinuxProcessList* this = (LinuxProcessList*) super; - LinuxProcessList_scanMemoryInfo(this); + LinuxProcessList_scanMemoryInfo(super); double period = LinuxProcessList_scanCPUTime(this); diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index cfd01828..5509bb50 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -50,16 +50,6 @@ typedef struct LinuxProcessList_ { CPUData* cpus; - unsigned long long int totalMem; - unsigned long long int usedMem; - unsigned long long int freeMem; - unsigned long long int sharedMem; - unsigned long long int buffersMem; - unsigned long long int cachedMem; - unsigned long long int totalSwap; - unsigned long long int usedSwap; - unsigned long long int freeSwap; - } LinuxProcessList; #ifndef PROCDIR diff --git a/linux/Platform.c b/linux/Platform.c index 5ade6e9d..b480fd01 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -149,7 +149,7 @@ double Platform_setCPUValues(Meter* this, int cpu) { } void Platform_setMemoryValues(Meter* this) { - LinuxProcessList* pl = (LinuxProcessList*) this->pl; + ProcessList* pl = (ProcessList*) this->pl; long int usedMem = pl->usedMem; long int buffersMem = pl->buffersMem; long int cachedMem = pl->cachedMem; @@ -161,7 +161,7 @@ void Platform_setMemoryValues(Meter* this) { } void Platform_setSwapValues(Meter* this) { - LinuxProcessList* pl = (LinuxProcessList*) this->pl; + ProcessList* pl = (ProcessList*) this->pl; this->total = pl->totalSwap; this->values[0] = pl->usedSwap; }