Skip to content

Commit 4b8b61f

Browse files
tanriolBenBE
authored andcommitted
ProcessList.h: remove ProcessList_remove
As the "highlight dying processes" option has to keep processes in the list when they disappear, no code except the cleanup loop in `ProcessList_scan` should remove processes from the list directly. Remove the export to prevent random process removals from being reintroduced accidentally.
1 parent fae7ff6 commit 4b8b61f

2 files changed

Lines changed: 1 addition & 12 deletions

File tree

ProcessList.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void ProcessList_add(ProcessList* this, Process* p) {
176176
// ProcessList_removeIndex removes Process p from the list's map and soft deletes
177177
// it from its vector. Vector_compact *must* be called once the caller is done
178178
// removing items.
179+
// Should only be called from ProcessList_scan to avoid breaking dying process highlighting.
179180
static void ProcessList_removeIndex(ProcessList* this, const Process* p, int idx) {
180181
pid_t pid = p->pid;
181182

@@ -194,16 +195,6 @@ static void ProcessList_removeIndex(ProcessList* this, const Process* p, int idx
194195
assert(Vector_countEquals(this->processes, Hashtable_count(this->processTable)));
195196
}
196197

197-
void ProcessList_remove(ProcessList* this, const Process* p) {
198-
int idx = Vector_indexOf(this->processes, p, Process_pidEqualCompare);
199-
assert(0 <= idx && idx < Vector_size(this->processes));
200-
if (idx >= 0) {
201-
ProcessList_removeIndex(this, p, idx);
202-
// This function is public so must not require callers to compact the Vector
203-
Vector_compact(this->processes);
204-
}
205-
}
206-
207198
static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level, int indent, bool show) {
208199
// On OpenBSD the kernel thread 'swapper' has pid 0.
209200
// Do not treat it as root of any tree.

ProcessList.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ void ProcessList_printHeader(const ProcessList* this, RichString* header);
106106

107107
void ProcessList_add(ProcessList* this, Process* p);
108108

109-
void ProcessList_remove(ProcessList* this, const Process* p);
110-
111109
void ProcessList_updateDisplayList(ProcessList* this);
112110

113111
ProcessField ProcessList_keyAt(const ProcessList* this, int at);

0 commit comments

Comments
 (0)