projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Treewide: cleanup whitespace
[collectd.git]
/
src
/
daemon
/
utils_cache.c
diff --git
a/src/daemon/utils_cache.c
b/src/daemon/utils_cache.c
index
3f7a596
..
b5b059c
100644
(file)
--- 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;
{
cache_entry_t *ce;
- ce =
(cache_entry_t *) malloc (sizeof (cache_entry_t
));
+ ce =
calloc (1, sizeof (*ce
));
if (ce == NULL)
{
if (ce == NULL)
{
- ERROR ("utils_cache: cache_alloc:
m
alloc failed.");
+ ERROR ("utils_cache: cache_alloc:
c
alloc failed.");
return (NULL);
}
return (NULL);
}
- memset (ce, '\0', sizeof (cache_entry_t));
ce->values_num = values_num;
ce->values_gauge = calloc (values_num, sizeof (*ce->values_gauge));
ce->values_num = values_num;
ce->values_gauge = calloc (values_num, sizeof (*ce->values_gauge));
@@
-193,12
+192,13
@@
static int uc_insert (const data_set_t *ds, const value_list_t *vl,
/ CDTIME_T_TO_DOUBLE (vl->interval);
ce->values_raw[i].absolute = vl->values[i].absolute;
break;
/ CDTIME_T_TO_DOUBLE (vl->interval);
ce->values_raw[i].absolute = vl->values[i].absolute;
break;
-
+
default:
/* This shouldn't happen. */
ERROR ("uc_insert: Don't know how to handle data source type %i.",
ds->ds[i].type);
sfree (key_copy);
default:
/* This shouldn't happen. */
ERROR ("uc_insert: Don't know how to handle data source type %i.",
ds->ds[i].type);
sfree (key_copy);
+ cache_free (ce);
return (-1);
} /* switch (ds->ds[i].type) */
} /* for (i) */
return (-1);
} /* switch (ds->ds[i].type) */
} /* for (i) */
@@
-246,7
+246,7
@@
int uc_check_timeout (void)
int status;
int i;
int status;
int i;
-
+
pthread_mutex_lock (&cache_lock);
now = cdtime ();
pthread_mutex_lock (&cache_lock);
now = cdtime ();
@@
-498,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;
else
{
ret_num = ce->values_num;
- ret =
(gauge_t *) malloc (ret_num * sizeof (gauge_
t));
+ ret =
malloc (ret_num * sizeof (*re
t));
if (ret == NULL)
{
ERROR ("utils_cache: uc_get_rate_by_name: malloc failed.");
if (ret == NULL)
{
ERROR ("utils_cache: uc_get_rate_by_name: malloc failed.");
@@
-558,7
+558,7
@@
gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl)
return (ret);
} /* gauge_t *uc_get_rate */
return (ret);
} /* gauge_t *uc_get_rate */
-size_t uc_get_size
(
) {
+size_t uc_get_size
(void
) {
size_t size_arrays = 0;
pthread_mutex_lock (&cache_lock);
size_t size_arrays = 0;
pthread_mutex_lock (&cache_lock);
@@
-735,7
+735,6
@@
int uc_get_history_by_name (const char *name,
if (ce->history_length < num_steps)
{
gauge_t *tmp;
if (ce->history_length < num_steps)
{
gauge_t *tmp;
- size_t i;
tmp = realloc (ce->history, sizeof (*ce->history)
* num_steps * ce->values_num);
tmp = realloc (ce->history, sizeof (*ce->history)
* num_steps * ce->values_num);