summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-05-01 20:45:07 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-05-01 20:45:07 +0000
commit4df92783284eca3950cc78c6c78e522098074110 (patch)
treef0ea4d46ccf168ef399fd959a51cbf52066bd327 /src
parenta73427fc0bc8c00ed3e6478ac57ac048cec4afdd (diff)
downloadpacman-4df92783284eca3950cc78c6c78e522098074110.tar.xz
reimplemented list_free() a safer way
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;
}