mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
rewrote list_free to not be recursive anymore
(it can trigger segmentation faults when freeing long lists)
This commit is contained in:
parent
7767095c59
commit
03f2ec2d0b
@ -68,18 +68,14 @@ PMList* pm_list_new()
|
||||
|
||||
void pm_list_free(PMList *list)
|
||||
{
|
||||
if(list == NULL) {
|
||||
return;
|
||||
PMList *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) {
|
||||
pm_list_free(list->next);
|
||||
}
|
||||
free(list);
|
||||
return;
|
||||
}
|
||||
|
||||
PMList* pm_list_add(PMList *list, void *data)
|
||||
|
Loading…
Reference in New Issue
Block a user