X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_llist.c;h=60273382dec81950cfa61a2273d3103f79a8f664;hb=667893e9be8a3a3f608d4b8550be9170732a0747;hp=09c9834d066cf6280ed993515adb36adc2176141;hpb=3812f29af0b4ae25d1e0114ee0afc4a83880e913;p=collectd.git diff --git a/src/daemon/utils_llist.c b/src/daemon/utils_llist.c index 09c9834d..60273382 100644 --- a/src/daemon/utils_llist.c +++ b/src/daemon/utils_llist.c @@ -24,8 +24,6 @@ * Florian Forster */ -#include "config.h" - #include #include @@ -48,12 +46,10 @@ llist_t *llist_create (void) { llist_t *ret; - ret = (llist_t *) malloc (sizeof (llist_t)); + ret = calloc (1, sizeof (*ret)); if (ret == NULL) return (NULL); - memset (ret, '\0', sizeof (llist_t)); - return (ret); } @@ -78,7 +74,7 @@ llentry_t *llentry_create (char *key, void *value) { llentry_t *e; - e = (llentry_t *) malloc (sizeof (llentry_t)); + e = malloc (sizeof (*e)); if (e) { e->key = key; @@ -123,6 +119,9 @@ void llist_remove (llist_t *l, llentry_t *e) { llentry_t *prev; + if ((l == NULL) || (e == NULL)) + return; + prev = l->head; while ((prev != NULL) && (prev->next != e)) prev = prev->next;