X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_fbhash.c;h=d1a580cd632420d0ab25e9a6186d5210e63d6b55;hb=f7a72570f9b5c0779c6c41d42aaf0d5f0dc1fb07;hp=70b89089dce13e73e2deb9f25b8db5942ccdaa70;hpb=24c2f247f6dc5c17b26d715346a380efababb08f;p=collectd.git diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c index 70b89089..d1a580cd 100644 --- a/src/utils_fbhash.c +++ b/src/utils_fbhash.c @@ -27,8 +27,6 @@ #include "collectd.h" #include "plugin.h" -#include - #include "utils_fbhash.h" #include "utils_avltree.h" @@ -41,7 +39,7 @@ struct fbhash_s c_avl_tree_t *tree; }; -/* +/* * Private functions */ static void fbh_free_tree (c_avl_tree_t *tree) /* {{{ */ @@ -93,7 +91,7 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ return (-1); } - tree = c_avl_create ((void *) strcmp); + tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (tree == NULL) { fclose (fh); @@ -198,7 +196,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 +207,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 +225,7 @@ fbhash_t *fbh_create (const char *file) /* {{{ */ if (status != 0) { fbh_destroy (h); + free (h); return (NULL); }