fixed some shitty bugs in remove_node

yay now like 4561456456 bugs remain
This commit is contained in:
Václav Šmejkal 2023-02-01 15:53:58 +01:00
parent 85731bab38
commit 115a4c20de
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -68,10 +68,14 @@ void remove_node(node_t *node) //valgrind says this causes memory leaks ('still
node -> next -> last = node -> last; node -> next -> last = node -> last;
} else } else
{ {
node -> last = NULL; node -> last -> next = NULL; //idk there could be some bugz
} }
if (head == NULL) free(head); //LIST IS EMPTY NOW => DEALLOCATE if (head -> next == NULL) //LIST IS EMPTY NOW => DEALLOCATE
{
free(head);
head = NULL;
}
//DEALLOCATION //DEALLOCATION
free(node); free(node);