X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=33b1a6fead7f9db643f71386f390dde345605333;hb=e030096e4f5a0bbdd42635bfeb95e39d150cac72;hp=556263f6f75bbbc87e74ccb893ba42285e11a537;hpb=00f9279d9711c9882b65d54fd72c2f25a3f403fc;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 556263f6..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 = (cj_key_t *) 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) @@ -615,7 +614,7 @@ static int cj_init_curl (cj_t *db) /* {{{ */ if (db->pass != NULL) credentials_size += strlen (db->pass); - db->credentials = (char *) malloc (credentials_size); + db->credentials = malloc (credentials_size); if (db->credentials == NULL) { ERROR ("curl_json plugin: malloc failed."); @@ -667,13 +666,12 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = (cj_t *) 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; @@ -861,7 +859,7 @@ static void cj_submit (cj_t *db, cj_key_t *key, value_t *value) /* {{{ */ static int cj_sock_perform (cj_t *db) /* {{{ */ { char errbuf[1024]; - struct sockaddr_un sa_unix = {}; + struct sockaddr_un sa_unix = { 0 }; sa_unix.sun_family = AF_UNIX; sstrncpy (sa_unix.sun_path, db->sock, sizeof (sa_unix.sun_path));