From 03f2ec2d0bf9ddd8e175afed3304a588694b9d15 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Sat, 26 Mar 2005 20:56:08 +0000 Subject: rewrote list_free to not be recursive anymore (it can trigger segmentation faults when freeing long lists) --- lib/libalpm/list.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'lib/libalpm/list.c') 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) -- cgit v1.2.3-54-g00ecf