X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_cache.c;h=e1cfac98f4ff0d39c184fc0c4d728bee421fda54;hb=dc3637c5113c79e83d8d104c88c9cc5057dc9dcb;hp=0756807334b7b4eba7bf05bb3757c3917de63878;hpb=5c2993e4121feae745551be182221b31bc23ff97;p=collectd.git diff --git a/src/daemon/utils_cache.c b/src/daemon/utils_cache.c index 07568073..e1cfac98 100644 --- a/src/daemon/utils_cache.c +++ b/src/daemon/utils_cache.c @@ -83,13 +83,12 @@ static cache_entry_t *cache_alloc (size_t values_num) { cache_entry_t *ce; - ce = (cache_entry_t *) malloc (sizeof (cache_entry_t)); + ce = calloc (1, sizeof (*ce)); if (ce == NULL) { - ERROR ("utils_cache: cache_alloc: malloc failed."); + ERROR ("utils_cache: cache_alloc: calloc failed."); return (NULL); } - memset (ce, '\0', sizeof (cache_entry_t)); ce->values_num = values_num; ce->values_gauge = calloc (values_num, sizeof (*ce->values_gauge)); @@ -499,7 +498,7 @@ int uc_get_rate_by_name (const char *name, gauge_t **ret_values, size_t *ret_val else { ret_num = ce->values_num; - ret = (gauge_t *) malloc (ret_num * sizeof (gauge_t)); + ret = malloc (ret_num * sizeof (*ret)); if (ret == NULL) { ERROR ("utils_cache: uc_get_rate_by_name: malloc failed.");