From: Ruben Kerkhof Date: Fri, 1 Apr 2016 16:22:52 +0000 (+0200) Subject: target plugins: malloc + memset -> calloc X-Git-Tag: collectd-5.6.0~371^2~12 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e7b4b1f7f9e56cecd797b854c5a96582c5f9dd57;p=collectd.git target plugins: malloc + memset -> calloc --- diff --git a/src/target_notification.c b/src/target_notification.c index d850a684..55b72ac1 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -126,13 +126,12 @@ static int tn_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 ("tn_create: malloc failed."); + ERROR ("tn_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->message = NULL; data->severity = 0; diff --git a/src/target_replace.c b/src/target_replace.c index 2166746c..545fa353 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; @@ -244,13 +243,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; diff --git a/src/target_scale.c b/src/target_scale.c index b667ed13..3ac399c9 100644 --- a/src/target_scale.c +++ b/src/target_scale.c @@ -387,13 +387,12 @@ static int ts_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 ("ts_create: malloc failed."); + ERROR ("ts_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->factor = NAN; data->offset = NAN; diff --git a/src/target_set.c b/src/target_set.c index a676a3d1..faad0bf5 100644 --- a/src/target_set.c +++ b/src/target_set.c @@ -87,13 +87,12 @@ static int ts_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 ("ts_create: malloc failed."); + ERROR ("ts_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->host = NULL; data->plugin = NULL;