I have no idea what I'm doing

This commit is contained in:
Václav Šmejkal 2023-02-01 16:10:51 +01:00
parent d1b3960799
commit f405c486c8
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -66,16 +66,17 @@ void remove_node(node_t *node) //valgrind says this causes memory leaks ('still
if (node -> next != NULL) if (node -> next != NULL)
{ {
node -> next -> last = node -> last; node -> next -> last = node -> last;
} else if (node -> last != NULL) } else
{
if (node -> last != NULL)
{ {
node -> last -> next = NULL; node -> last -> next = NULL;
} } else //LIST IS EMPTY NOW => DEALLOCATE
if (head -> next == NULL) //LIST IS EMPTY NOW => DEALLOCATE
{ {
free(head); free(head);
head = NULL; head = NULL;
} }
}
//DEALLOCATION //DEALLOCATION
free(node); free(node);