X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftarget_replace.c;h=8d774c570f849d7beed5e378a7d936c5d6f2a070;hb=d26dd5c1db5c3310c9e69b2b910c6547469c99ce;hp=2166746c1246e99657739856994edc8286fbd083;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/target_replace.c b/src/target_replace.c index 2166746c..8d774c57 100644 --- a/src/target_replace.c +++ b/src/target_replace.c @@ -102,13 +102,12 @@ static int tr_config_add_action (tr_action_t **dest, /* {{{ */ return (-1); } - act = malloc (sizeof (*act)); + act = calloc (1, sizeof (*act)); if (act == NULL) { - ERROR ("tr_config_add_action: malloc failed."); + ERROR ("tr_config_add_action: calloc failed."); return (-ENOMEM); } - memset (act, 0, sizeof (*act)); act->replacement = NULL; act->may_be_empty = may_be_empty; @@ -159,13 +158,12 @@ static int tr_action_invoke (tr_action_t *act_head, /* {{{ */ tr_action_t *act; int status; char buffer[DATA_MAX_NAME_LEN]; - regmatch_t matches[8]; + regmatch_t matches[8] = { [0] = { 0 } }; if (act_head == NULL) return (-EINVAL); sstrncpy (buffer, buffer_in, sizeof (buffer)); - memset (matches, 0, sizeof (matches)); DEBUG ("target_replace plugin: tr_action_invoke: <- buffer = %s;", buffer); @@ -244,13 +242,12 @@ static int tr_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ int status; int i; - data = malloc (sizeof (*data)); + data = calloc (1, sizeof (*data)); if (data == NULL) { - ERROR ("tr_create: malloc failed."); + ERROR ("tr_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->host = NULL; data->plugin = NULL; @@ -348,9 +345,8 @@ static int tr_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 = tr_create; tproc.destroy = tr_destroy; tproc.invoke = tr_invoke;