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
This commit is contained in:
Václav Šmejkal 2023-02-01 15:06:00 +01:00
parent c8e2c4226d
commit 66560fd033
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -113,12 +113,13 @@ void why2_free(void *pointer)
node_t *node_buffer = head; node_t *node_buffer = head;
//FIND pointer IN LINKED LIST //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 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); free(pointer);
} }