X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_scale.c;h=8659c8d7ba63fdaed6658ab48fb6cbea041ac49f;hb=063a5e75b36173e89ffa18d32d47509f6ef968ec;hp=6169fa05d585ce4c7a97abc6c882b80dbbeb78db;hpb=4ac3040668e7a9b595edd334a9179a5f6ae42461;p=collectd.git diff --git a/src/target_scale.c b/src/target_scale.c index 6169fa05..8659c8d7 100644 --- a/src/target_scale.c +++ b/src/target_scale.c @@ -25,6 +25,7 @@ **/ #include "collectd.h" + #include "common.h" #include "filter_chain.h" @@ -328,7 +329,7 @@ static int ts_config_add_data_source(ts_data_t *data, /* {{{ */ /* Allocate space for the char pointers */ new_data_sources_num = data->data_sources_num + ((size_t) ci->values_num); - temp = (char **) realloc (data->data_sources, + temp = realloc (data->data_sources, new_data_sources_num * sizeof (char *)); if (temp == NULL) { @@ -387,13 +388,12 @@ static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ int status; int i; - data = (ts_data_t *) malloc (sizeof (*data)); + data = calloc (1, sizeof (*data)); if (data == NULL) { - ERROR ("ts_create: malloc failed."); + ERROR ("ts_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->factor = NAN; data->offset = NAN; @@ -491,9 +491,8 @@ static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ void module_register (void) { - target_proc_t tproc; + target_proc_t tproc = { 0 }; - memset (&tproc, 0, sizeof (tproc)); tproc.create = ts_create; tproc.destroy = ts_destroy; tproc.invoke = ts_invoke;