From 442050c2926d7cb477d02d26cd5bfab58ce07c77 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Fri, 1 Apr 2016 17:11:17 +0200 Subject: [PATCH] memcached plugin: malloc + memset -> calloc --- src/memcached.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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; -- 2.30.2