X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_fbhash.c;h=f27c08272cb5cde3734975236164943bcd2757bd;hb=b81104a423234c04f0eb4ace0ec5e93a363c917a;hp=70b89089dce13e73e2deb9f25b8db5942ccdaa70;hpb=0003c4d3c184f0f437499d6073cd023dc7b659c2;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); }