From 4db24ca28a31d1d0d97b30b186fd5255a0ae0113 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 23 Jan 2007 01:34:58 +0000 Subject: * Added some calloc calls to replace the malloc-then-set-to-zero functionality * Fixed -Ss output so as not to call alpm_list_getdata with a NULl list * Added a NULL check in alpm_list_getdata * Fixed alpm_list_add_sorted to properly handle a new / beginning insertions --- lib/libalpm/alpm_list.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/alpm_list.c') diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index a43f8211..26fcb3dc 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -145,8 +145,10 @@ alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cm if(prev != NULL) { prev->next = add; /* In middle. */ + } else { + list = add; /* At beginning, or new list */ } - + return(list); } } @@ -369,6 +371,7 @@ alpm_list_t *alpm_list_last(alpm_list_t *list) */ void *alpm_list_getdata(const alpm_list_t *entry) { + if(entry == NULL) return(NULL); return(entry->data); } -- cgit v1.2.3-24-g4f1b