From 1ef8c0e12f29606cb5bfb77d9bce78ae5e6bbb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 16 Dec 2021 15:57:37 +0100 Subject: [PATCH] Drop getCommandStr member of Process Formatting the merged command string is now implemented in an platform independent way. Drop the Process member getCommandStr designed for overrides of individual platforms. --- Process.c | 5 ++--- Process.h | 8 ++------ unsupported/UnsupportedProcess.c | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Process.c b/Process.c index 5214e97a..3f0da978 100644 --- a/Process.c +++ b/Process.c @@ -397,7 +397,7 @@ static inline char* stpcpyWithNewlineConversion(char* dstStr, const char* srcStr * This function makes the merged Command string. It also stores the offsets of the * basename, comm w.r.t the merged Command string - these offsets will be used by * Process_writeCommand() for coloring. The merged Command string is also - * returned by Process_getCommandStr() for searching, sorting and filtering. + * returned by Process_getCommand() for searching, sorting and filtering. */ void Process_makeCommandStr(Process* this) { ProcessMergedCommand* mc = &this->mergedCommand; @@ -1011,7 +1011,7 @@ void Process_done(Process* this) { /* This function returns the string displayed in Command column, so that sorting * happens on what is displayed - whether comm, full path, basename, etc.. So * this follows Process_writeField(COMM) and Process_writeCommand */ -const char* Process_getCommandStr(const Process* this) { +const char* Process_getCommand(const Process* this) { if ((Process_isUserlandThread(this) && this->settings->showThreadNames) || !this->mergedCommand.str) { return this->cmdline; } @@ -1027,7 +1027,6 @@ const ProcessClass Process_class = { .compare = Process_compare }, .writeField = Process_writeField, - .getCommandStr = Process_getCommandStr, }; void Process_init(Process* this, const Settings* settings) { diff --git a/Process.h b/Process.h index 26f64349..d6a1f996 100644 --- a/Process.h +++ b/Process.h @@ -296,18 +296,15 @@ extern int Process_uidDigits; typedef Process* (*Process_New)(const struct Settings_*); typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField); typedef int (*Process_CompareByKey)(const Process*, const Process*, ProcessField); -typedef const char* (*Process_GetCommandStr)(const Process*); typedef struct ProcessClass_ { const ObjectClass super; const Process_WriteField writeField; const Process_CompareByKey compareByKey; - const Process_GetCommandStr getCommandStr; } ProcessClass; #define As_Process(this_) ((const ProcessClass*)((this_)->super.klass)) -#define Process_getCommand(this_) (As_Process(this_)->getCommandStr ? As_Process(this_)->getCommandStr((const Process*)(this_)) : Process_getCommandStr((const Process*)(this_))) #define Process_compareByKey(p1_, p2_, key_) (As_Process(p1_)->compareByKey ? (As_Process(p1_)->compareByKey(p1_, p2_, key_)) : Process_compareByKey_Base(p1_, p2_, key_)) static inline pid_t Process_getParentPid(const Process* this) { @@ -397,15 +394,14 @@ int Process_pidCompare(const void* v1, const void* v2); int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key); -// Avoid direct calls, use Process_getCommand instead -const char* Process_getCommandStr(const Process* this); +const char* Process_getCommand(const Process* this); void Process_updateComm(Process* this, const char* comm); void Process_updateCmdline(Process* this, const char* cmdline, int basenameStart, int basenameEnd); void Process_updateExe(Process* this, const char* exe); /* This function constructs the string that is displayed by - * Process_writeCommand and also returned by Process_getCommandStr */ + * Process_writeCommand and also returned by Process_getCommand */ void Process_makeCommandStr(Process* this); void Process_writeCommand(const Process* this, int attr, int baseAttr, RichString* str); diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c index b1f63c6a..99c2144a 100644 --- a/unsupported/UnsupportedProcess.c +++ b/unsupported/UnsupportedProcess.c @@ -100,6 +100,5 @@ const ProcessClass UnsupportedProcess_class = { .compare = Process_compare }, .writeField = UnsupportedProcess_writeField, - .getCommandStr = NULL, .compareByKey = UnsupportedProcess_compareByKey };