summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-02-20 14:52:10 -0200
committerHisham Muhammad <hisham@gobolinux.org>2015-02-23 01:13:40 -0300
commit9780c312f40633a2ce23300cc76faf64e07a87ed (patch)
tree1d04f7070e5183f6f9aad77c91d4d81025868a24 /linux
parentcce2202a1ffdce2d6d775e3d0d5ced092d823598 (diff)
Fix allocation of processes. Closes #166.
Conflicts: Process.c Process.h ProcessList.c ScreenManager.c linux/LinuxProcessList.c
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcess.c16
-rw-r--r--linux/LinuxProcess.h6
-rw-r--r--linux/LinuxProcessList.c5
-rw-r--r--linux/Platform.c1
-rw-r--r--linux/Platform.h1
5 files changed, 27 insertions, 2 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index be4e627a..9c26018d 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -10,6 +10,7 @@ in the source distribution for its full text.
#include "LinuxProcess.h"
#include "CRT.h"
+#include <stdlib.h>
#include <unistd.h>
#include <sys/syscall.h>
@@ -22,8 +23,23 @@ typedef struct LinuxProcess_ {
IOPriority ioPriority;
} LinuxProcess;
+#define Process_delete LinuxProcess_delete
+
}*/
+LinuxProcess* LinuxProcess_new(Settings* settings, ProcessList* pl) {
+ LinuxProcess* this = calloc(sizeof(LinuxProcess), 1);
+ Process_init(&this->super, settings, pl);
+ return this;
+}
+
+void LinuxProcess_delete(Object* cast) {
+ LinuxProcess* this = (LinuxProcess*) this;
+ Object_setClass(this, Class(Process));
+ Process_done((Process*)cast);
+ free(this);
+}
+
/*
[1] Note that before kernel 2.6.26 a process that has not asked for
an io priority formally uses "none" as scheduling class, but the
diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h
index 97ddf90b..ec2740e9 100644
--- a/linux/LinuxProcess.h
+++ b/linux/LinuxProcess.h
@@ -17,6 +17,12 @@ typedef struct LinuxProcess_ {
IOPriority ioPriority;
} LinuxProcess;
+#define Process_delete LinuxProcess_delete
+
+
+LinuxProcess* LinuxProcess_new(Settings* settings);
+
+void LinuxProcess_delete(Object* cast);
/*
[1] Note that before kernel 2.6.26 a process that has not asked for
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index c2d3fa7c..2bce78e5 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -319,6 +319,7 @@ static void LinuxProcessList_readCGroupFile(Process* process, const char* dirnam
int nFields;
char** fields = String_split(trimmed, ':', &nFields);
free(trimmed);
+ free(process->cgroup);
if (nFields >= 3) {
process->cgroup = strndup(fields[2] + 1, 10);
} else {
@@ -464,7 +465,7 @@ static bool LinuxProcessList_processEntries(ProcessList* this, const char* dirna
process = existingProcess;
assert(process->pid == pid);
} else {
- process = Process_new(this);
+ process = (Process*) LinuxProcess_new(settings, this);
assert(process->comm == NULL);
process->pid = pid;
process->tgid = parent ? parent->pid : pid;
@@ -568,7 +569,7 @@ static bool LinuxProcessList_processEntries(ProcessList* this, const char* dirna
if (existingProcess)
ProcessList_remove(this, process);
else
- Process_delete((Object*)process);
+ LinuxProcess_delete((Object*)process);
}
}
closedir(dir);
diff --git a/linux/Platform.c b/linux/Platform.c
index ee5abf81..70a0f55c 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -27,6 +27,7 @@ in the source distribution for its full text.
/*{
#include "Action.h"
#include "BatteryMeter.h"
+#include "LinuxProcess.h"
}*/
static Htop_Reaction Platform_actionSetIOPriority(Panel* panel, ProcessList* pl, Header* header) {
diff --git a/linux/Platform.h b/linux/Platform.h
index 2058419c..446c51d1 100644
--- a/linux/Platform.h
+++ b/linux/Platform.h
@@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "Action.h"
#include "BatteryMeter.h"
+#include "LinuxProcess.h"
void Platform_setBindings(Htop_Action* keys);

© 2014-2024 Faster IT GmbH | imprint | privacy policy