X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_fbhash.c;h=f27c08272cb5cde3734975236164943bcd2757bd;hb=354f9991530248e45207d236eb74c1cc3d5238ef;hp=70b89089dce13e73e2deb9f25b8db5942ccdaa70;hpb=f701e685eab83f37ecc6501d7dbe4eb941a454bb;p=collectd.git diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c index 70b89089..f27c0827 100644 --- a/src/utils_fbhash.c +++ b/src/utils_fbhash.c @@ -41,7 +41,7 @@ struct fbhash_s c_avl_tree_t *tree; }; -/* +/* * Private functions */ static void fbh_free_tree (c_avl_tree_t *tree) /* {{{ */ @@ -198,7 +198,7 @@ static int fbh_check_file (fbhash_t *h) /* {{{ */ return (status); } /* }}} int fbh_check_file */ -/* +/* * Public functions */ fbhash_t *fbh_create (const char *file) /* {{{ */ @@ -209,10 +209,9 @@ fbhash_t *fbh_create (const char *file) /* {{{ */ if (file == NULL) return (NULL); - h = malloc (sizeof (*h)); + h = calloc (1, sizeof (*h)); if (h == NULL) return (NULL); - memset (h, 0, sizeof (*h)); h->filename = strdup (file); if (h->filename == NULL) @@ -228,6 +227,7 @@ fbhash_t *fbh_create (const char *file) /* {{{ */ if (status != 0) { fbh_destroy (h); + free (h); return (NULL); }