1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-10-31 15:45:03 -04:00

reimplemented list_free() a safer way

This commit is contained in:
Aurelien Foret 2005-05-01 20:45:07 +00:00
parent a73427fc0b
commit 4df9278328

View File

@ -45,17 +45,14 @@ list_t *list_new()
void list_free(list_t *list)
{
if(list == NULL) {
return;
list_t *ptr, *it = list;
while(it) {
ptr = it->next;
free(it->data);
free(it);
it = ptr;
}
if(list->data != NULL) {
free(list->data);
list->data = NULL;
}
if(list->next != NULL) {
list_free(list->next);
}
free(list);
return;
}