From: Ruben Kerkhof Date: Mon, 28 Mar 2016 17:50:38 +0000 (+0200) Subject: curl_json: malloc + memset -> calloc X-Git-Tag: collectd-5.6.0~371^2~47 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b59a0c002d8e0c58a3eeb0c82eb01026395b6b7d;p=collectd.git curl_json: malloc + memset -> calloc --- diff --git a/src/curl_json.c b/src/curl_json.c index 4fa6f33b..33b1a6fe 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -474,13 +474,12 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ return (-1); } - key = malloc (sizeof (*key)); + key = calloc (1, sizeof (*key)); if (key == NULL) { - ERROR ("curl_json plugin: malloc failed."); + ERROR ("curl_json plugin: calloc failed."); return (-1); } - memset (key, 0, sizeof (*key)); key->magic = CJ_KEY_MAGIC; if (strcasecmp ("Key", ci->key) == 0) @@ -667,13 +666,12 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = malloc (sizeof (*db)); + db = calloc (1, sizeof (*db)); if (db == NULL) { - ERROR ("curl_json plugin: malloc failed."); + ERROR ("curl_json plugin: calloc failed."); return (-1); } - memset (db, 0, sizeof (*db)); db->timeout = -1;