From 66560fd0334f4d6428fd34f446faec90f39a5fc4 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 1 Feb 2023 15:06:00 +0100 Subject: [PATCH] reformated why2_free I just realized I am freeing with why2_free ALL THE TIME, so it is causing some problems when freeing like strdup or anything --- src/core/lib/utils/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 6769b2b..e58f558 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -113,12 +113,13 @@ void why2_free(void *pointer) node_t *node_buffer = head; //FIND pointer IN LINKED LIST - while (node_buffer -> next != NULL) //if pointer won't be found, nothing will happen | idk if I wanna fix this or leave it like this + while (node_buffer -> next != NULL) { - node_buffer = node_buffer -> next; if (node_buffer -> pointer == pointer) break; //FOUND + + node_buffer = node_buffer -> next; } - remove_node(node_buffer); + remove_node(node_buffer); //REMOVE FROM LIST | IF ISN'T FOUND, PROBABLY WILL CAUSE SEGFAULT (I WON'T MAKE IT SAFE; FUCK YOU - USE why2_free ONLY IF YOU ALLOCATED WITH why2_foo) free(pointer); } \ No newline at end of file