From 97ea7a1a8c5f6356b1b961fca3dc7cc2cf10bfc4 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 8 Nov 2006 22:16:46 +0000 Subject: [PATCH] Ok, second take on fixing the handling of comm.- --- Process.c | 1 + ProcessList.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Process.c b/Process.c index e0d9b352..5fc3e835 100644 --- a/Process.c +++ b/Process.c @@ -140,6 +140,7 @@ Process* Process_new(struct ProcessList_ *pl) { Process* Process_clone(Process* this) { Process* clone = malloc(sizeof(Process)); memcpy(clone, this, sizeof(Process)); + this->comm = NULL; return clone; } diff --git a/ProcessList.c b/ProcessList.c index d2d67c3e..c3f0dc5a 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -526,10 +526,7 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl assert(process->pid == pid); } else { process = prototype; - if (process->comm) { - free(process->comm); - process->comm = NULL; - } + assert(process->comm == NULL); process->pid = pid; if (! ProcessList_readStatusFile(this, process, dirname, name)) goto errorReadingProcess; @@ -611,6 +608,10 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl errorReadingProcess: { if (existingProcess) ProcessList_remove(this, process); + if (process->comm) { + free(process->comm); + process->comm = NULL; + } } } }