summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-26 20:56:08 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-26 20:56:08 +0000
commit03f2ec2d0bf9ddd8e175afed3304a588694b9d15 (patch)
tree591d740c3c6d3fbda1b6abadb33171d217107552 /lib/libalpm
parent7767095c599d73081d43ac33ff7478fc625e2d74 (diff)
rewrote list_free to not be recursive anymore
(it can trigger segmentation faults when freeing long lists)
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/list.c18
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)