#include "collectd.h"
-#include <pthread.h>
-
#include "plugin.h"
#include "common.h"
#include "configfile.h"
DEBUG ("aggregation plugin: Creating new instance.");
- inst = malloc (sizeof (*inst));
+ inst = calloc (1, sizeof (*inst));
if (inst == NULL)
{
- ERROR ("aggregation plugin: malloc() failed.");
+ ERROR ("aggregation plugin: calloc() failed.");
return (NULL);
}
- memset (inst, 0, sizeof (*inst));
pthread_mutex_init (&inst->lock, /* attr = */ NULL);
inst->ds_type = ds->ds[0].type;
#define INIT_STATE(field) do { \
inst->state_ ## field = NULL; \
if (agg->calc_ ## field) { \
- inst->state_ ## field = malloc (sizeof (*inst->state_ ## field)); \
+ inst->state_ ## field = calloc (1, sizeof (*inst->state_ ## field)); \
if (inst->state_ ## field == NULL) { \
agg_instance_destroy (inst); \
free (inst); \
- ERROR ("aggregation plugin: malloc() failed."); \
+ ERROR ("aggregation plugin: calloc() failed."); \
return (NULL); \
} \
- memset (inst->state_ ## field, 0, sizeof (*inst->state_ ## field)); \
} \
} while (0)
char const *func, gauge_t rate, rate_to_value_state_t *state,
value_list_t *vl, char const *pi_prefix, cdtime_t t)
{
- value_t v;
+ value_t v = { 0 } ;
int status;
if (pi_prefix[0] != 0)
else
sstrncpy (vl->plugin_instance, func, sizeof (vl->plugin_instance));
- memset (&v, 0, sizeof (v));
status = rate_to_value (&v, rate, state, inst->ds_type, t);
if (status != 0)
{
int status;
int i;
- agg = malloc (sizeof (*agg));
+ agg = calloc (1, sizeof (*agg));
if (agg == NULL)
{
- ERROR ("aggregation plugin: malloc failed.");
+ ERROR ("aggregation plugin: calloc failed.");
return (-1);
}
- memset (agg, 0, sizeof (*agg));
sstrncpy (agg->ident.host, "/.*/", sizeof (agg->ident.host));
sstrncpy (agg->ident.plugin, "/.*/", sizeof (agg->ident.plugin));