X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_cache.c;h=9328d7ad9b413218c71b36920df36029c426d0c3;hb=441e067a2d5a294517bd87ca45c87fd67377d2cf;hp=7f0d228f095c02faf43296c0af0f4889b5231e1f;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/daemon/utils_cache.c b/src/daemon/utils_cache.c index 7f0d228f..9328d7ad 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 = malloc (sizeof (*ce)); + 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)); @@ -247,7 +246,7 @@ int uc_check_timeout (void) int status; int i; - + pthread_mutex_lock (&cache_lock); now = cdtime (); @@ -264,7 +263,7 @@ int uc_check_timeout (void) continue; /* If entry has not been updated, add to `keys' array */ - tmp = (char **) realloc ((void *) keys, + tmp = realloc ((void *) keys, (keys_len + 1) * sizeof (char *)); if (tmp == NULL) {