From d37d66bb3a089b9e66c6629a4855560984ac720d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Fri, 12 Mar 2021 16:46:55 +0100 Subject: [PATCH] InfoScreen/ProcessList: do not access Vector internals Use wrapper function to encapsulate the Vector structure --- InfoScreen.c | 2 +- ProcessList.c | 2 +- Vector.h | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/InfoScreen.c b/InfoScreen.c index 80e04837..4a1f6592 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -28,7 +28,7 @@ InfoScreen* InfoScreen_init(InfoScreen* this, const Process* process, FunctionBa } this->display = Panel_new(0, 1, COLS, height, Class(ListItem), false, bar); this->inc = IncSet_new(bar); - this->lines = Vector_new(this->display->items->type, true, DEFAULT_SIZE); + this->lines = Vector_new(Vector_type(this->display->items), true, DEFAULT_SIZE); Panel_setHeader(this->display, panelHeader); return this; } diff --git a/ProcessList.c b/ProcessList.c index 869bde44..cb89b720 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -202,7 +202,7 @@ static void ProcessList_updateTreeSetLayer(ProcessList* this, unsigned int leftB if (layerSize == 0) return; - Vector* layer = Vector_new(this->processes->type, false, layerSize); + Vector* layer = Vector_new(Vector_type(this->processes), false, layerSize); // Find all processes on the same layer (process with the same `deep` value // and included in a range from `leftBound` to `rightBound`). diff --git a/Vector.h b/Vector.h index 875f361d..dab94693 100644 --- a/Vector.h +++ b/Vector.h @@ -68,6 +68,10 @@ static inline int Vector_size(const Vector* this) { #endif /* NDEBUG */ +static inline const ObjectClass* Vector_type(const Vector* this) { + return this->type; +} + void Vector_add(Vector* this, void* data_); int Vector_indexOf(const Vector* this, const void* search_, Object_Compare compare);