From: Ruben Kerkhof Date: Fri, 1 Apr 2016 14:51:57 +0000 (+0200) Subject: libcollectdclient: malloc + memset -> calloc X-Git-Tag: collectd-5.6.0~371^2~36 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6075508e0d99fc667f8a80d1f954e2392d45c73b;p=collectd.git libcollectdclient: malloc + memset -> calloc --- diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index aeb8f22a..8b5ac0bd 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -584,10 +584,9 @@ int lcc_connect (const char *address, lcc_connection_t **ret_con) /* {{{ */ if (ret_con == NULL) return (-1); - c = malloc (sizeof (*c)); + c = calloc (1, sizeof (*c)); if (c == NULL) return (-1); - memset (c, 0, sizeof (*c)); status = lcc_open_socket (c, address); if (status != 0) diff --git a/src/libcollectdclient/network.c b/src/libcollectdclient/network.c index 7a866ee7..4564fbbe 100644 --- a/src/libcollectdclient/network.c +++ b/src/libcollectdclient/network.c @@ -271,10 +271,9 @@ lcc_network_t *lcc_network_create (void) /* {{{ */ { lcc_network_t *net; - net = malloc (sizeof (*net)); + net = calloc (1, sizeof (*net)); if (net == NULL) return (NULL); - memset (net, 0, sizeof (*net)); net->servers = NULL; @@ -299,10 +298,9 @@ lcc_server_t *lcc_server_create (lcc_network_t *net, /* {{{ */ if (service == NULL) service = NET_DEFAULT_PORT; - srv = malloc (sizeof (*srv)); + srv = calloc (1, sizeof (*srv)); if (srv == NULL) return (NULL); - memset (srv, 0, sizeof (*srv)); srv->fd = -1; srv->security_level = NONE; diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 343c285a..130da235 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -651,19 +651,17 @@ lcc_network_buffer_t *lcc_network_buffer_create (size_t size) /* {{{ */ return (NULL); } - nb = malloc (sizeof (*nb)); + nb = calloc (1, sizeof (*nb)); if (nb == NULL) return (NULL); - memset (nb, 0, sizeof (*nb)); nb->size = size; - nb->buffer = malloc (nb->size); + nb->buffer = calloc (1, nb->size); if (nb->buffer == NULL) { free (nb); return (NULL); } - memset (nb->buffer, 0, nb->size); nb->ptr = nb->buffer; nb->free = nb->size;