summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/list.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/pacman/list.c b/src/pacman/list.c
index c639e124..1d32b0b8 100644
--- a/src/pacman/list.c
+++ b/src/pacman/list.c
@@ -45,17 +45,14 @@ list_t *list_new()
void list_free(list_t *list)
{
- if(list == NULL) {
- return;
- }
- if(list->data != NULL) {
- free(list->data);
- list->data = NULL;
- }
- if(list->next != NULL) {
- list_free(list->next);
+ list_t *ptr, *it = list;
+
+ while(it) {
+ ptr = it->next;
+ free(it->data);
+ free(it);
+ it = ptr;
}
- free(list);
return;
}