summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/list.h
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-02-22 21:49:33 +0100
committerAurelien Foret <aurelien@archlinux.org>2006-02-22 21:49:33 +0100
commit16ff7cfa8ef2d50c97d79357c2b2c1fdc2bc241b (patch)
treed259cc5a0de95d478c3a21df549dbd90880147cd /lib/libalpm/list.h
parent78ffd98701b64bff74fc530db91ffc7e8768989a (diff)
downloadpacman-16ff7cfa8ef2d50c97d79357c2b2c1fdc2bc241b.tar.gz
pacman-16ff7cfa8ef2d50c97d79357c2b2c1fdc2bc241b.tar.xz
improved _alpm_list_free handling
Diffstat (limited to 'lib/libalpm/list.h')
-rw-r--r--lib/libalpm/list.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/libalpm/list.h b/lib/libalpm/list.h
index 0052efc4..7cfc886f 100644
--- a/lib/libalpm/list.h
+++ b/lib/libalpm/list.h
@@ -31,20 +31,16 @@ typedef struct __pmlist_t {
typedef struct __pmlist_t PMList;
-#define FREELIST(p) do { if(p) { _alpm_list_free(p); p = NULL; } } while(0)
-#define FREELISTPTR(p) do { \
- PMList *i; \
- for(i = p; i; i = i->next) { \
- i->data = NULL; \
- } \
- FREELIST(p); \
-} while(0)
+#define _FREELIST(p, f) do { if(p) { _alpm_list_free(p, f); p = NULL; } } while(0)
+#define FREELIST(p) _FREELIST(p, free)
+#define FREELISTPTR(p) _FREELIST(p, NULL)
+typedef void (*_alpm_fn_free) (void *);
/* Sort comparison callback function declaration */
typedef int (*_alpm_fn_cmp) (const void *, const void *);
PMList *_alpm_list_new(void);
-void _alpm_list_free(PMList *list);
+void _alpm_list_free(PMList *list, _alpm_fn_free fn);
PMList *_alpm_list_add(PMList *list, void *data);
PMList *_alpm_list_add_sorted(PMList *list, void *data, _alpm_fn_cmp fn);
PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void **data);