X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_heap.c;h=19b1d5b9db31c4b3e7ae10dbfc29daccac95cde8;hb=21058a13ed34ade6d2de0f54e4216b255d033af1;hp=1b5dca736ba59da0cf05a81ecf4a336dd378bbca;hpb=3812f29af0b4ae25d1e0114ee0afc4a83880e913;p=collectd.git diff --git a/src/daemon/utils_heap.c b/src/daemon/utils_heap.c index 1b5dca73..19b1d5b9 100644 --- a/src/daemon/utils_heap.c +++ b/src/daemon/utils_heap.c @@ -112,14 +112,13 @@ c_heap_t *c_heap_create (int (*compare) (const void *, const void *)) if (compare == NULL) return (NULL); - h = malloc (sizeof (*h)); + h = calloc (1, sizeof (*h)); if (h == NULL) return (NULL); - memset (h, 0, sizeof (*h)); pthread_mutex_init (&h->lock, /* attr = */ NULL); h->compare = compare; - + h->list = NULL; h->list_len = 0; h->list_size = 0; @@ -174,7 +173,7 @@ int c_heap_insert (c_heap_t *h, void *ptr) /* Reorganize the heap from bottom up. */ reheap (h, /* parent of this node = */ (index - 1) / 2, DIR_UP); - + pthread_mutex_unlock (&h->lock); return (0); } /* int c_heap_insert */