summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
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)