mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Fix allocation of processes. Closes #166.
Conflicts: Process.c Process.h ProcessList.c ScreenManager.c linux/LinuxProcessList.c
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user