From: Ruben Kerkhof Date: Fri, 1 Apr 2016 15:11:17 +0000 (+0200) Subject: memcached plugin: malloc + memset -> calloc X-Git-Tag: collectd-5.6.0~371^2~32 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=442050c2926d7cb477d02d26cd5bfab58ce07c77;p=collectd.git memcached plugin: malloc + memset -> calloc --- diff --git a/src/memcached.c b/src/memcached.c index 2c01a576..4e7b1431 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -587,14 +587,13 @@ static int config_add_instance(oconfig_item_t *ci) /* Disable automatic generation of default instance in the init callback. */ memcached_have_instances = 1; - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) { - ERROR ("memcached plugin: malloc failed."); + ERROR ("memcached plugin: calloc failed."); return (-1); } - memset (st, 0, sizeof (*st)); st->name = NULL; st->socket = NULL; st->host = NULL; @@ -685,10 +684,9 @@ static int memcached_init (void) return (0); /* No instances were configured, lets start a default instance. */ - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) return (ENOMEM); - memset (st, 0, sizeof (*st)); st->name = sstrdup ("__legacy__"); st->socket = NULL; st->host = NULL;