diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2005-03-26 20:56:08 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2005-03-26 20:56:08 +0000 |
commit | 03f2ec2d0bf9ddd8e175afed3304a588694b9d15 (patch) | |
tree | 591d740c3c6d3fbda1b6abadb33171d217107552 | |
parent | 7767095c599d73081d43ac33ff7478fc625e2d74 (diff) | |
download | pacman-03f2ec2d0bf9ddd8e175afed3304a588694b9d15.tar.xz |
rewrote list_free to not be recursive anymore
(it can trigger segmentation faults when freeing long lists)
-rw-r--r-- | lib/libalpm/list.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/libalpm/list.c b/lib/libalpm/list.c index bbd3c734..5a24f023 100644 --- a/lib/libalpm/list.c +++ b/lib/libalpm/list.c @@ -68,18 +68,14 @@ PMList* pm_list_new() void pm_list_free(PMList *list) { - if(list == NULL) { - return; - } - if(list->data != NULL) { - free(list->data); - list->data = NULL; - } - if(list->next != NULL) { - pm_list_free(list->next); + PMList *ptr, *it = list; + + while(it) { + ptr = it->next; + free(it->data); + free(it); + it = ptr; } - free(list); - return; } PMList* pm_list_add(PMList *list, void *data) |