X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcachec.c;h=629b99bab12dc9fa5290c3cb8bb34e87ef3d7bb5;hb=95dcf60c822e4ab92c0dd1a7ff6cba73bc55bcd1;hp=7c8528d500492751cd035f580000a487f42d3cb6;hpb=ef4a3db895a0aba7107c0f1c6c2ef2a7f128aaf8;p=collectd.git diff --git a/src/memcachec.c b/src/memcachec.c index 7c8528d5..629b99ba 100644 --- a/src/memcachec.c +++ b/src/memcachec.c @@ -18,7 +18,7 @@ * * Authors: * Doug MacEachern - * Florian octo Forster + * Florian octo Forster **/ #include "collectd.h" @@ -206,13 +206,12 @@ static int cmc_config_add_match (web_page_t *page, /* {{{ */ WARNING ("memcachec plugin: Ignoring arguments for the `Match' block."); } - match = (web_match_t *) malloc (sizeof (*match)); + match = calloc (1, sizeof (*match)); if (match == NULL) { - ERROR ("memcachec plugin: malloc failed."); + ERROR ("memcachec plugin: calloc failed."); return (-1); } - memset (match, 0, sizeof (*match)); status = 0; for (i = 0; i < ci->children_num; i++) @@ -263,7 +262,10 @@ static int cmc_config_add_match (web_page_t *page, /* {{{ */ } /* while (status == 0) */ if (status != 0) + { + cmc_web_match_free (match); return (status); + } match->match = match_create_simple (match->regex, match->exclude_regex, match->dstype); @@ -302,13 +304,12 @@ static int cmc_config_add_page (oconfig_item_t *ci) /* {{{ */ return (-1); } - page = (web_page_t *) malloc (sizeof (*page)); + page = calloc (1, sizeof (*page)); if (page == NULL) { - ERROR ("memcachec plugin: malloc failed."); + ERROR ("memcachec plugin: calloc failed."); return (-1); } - memset (page, 0, sizeof (*page)); page->server = NULL; page->key = NULL; @@ -386,7 +387,7 @@ static int cmc_config_add_page (oconfig_item_t *ci) /* {{{ */ web_page_t *prev; prev = pages_g; - while ((prev != NULL) && (prev->next != NULL)) + while (prev->next != NULL) prev = prev->next; prev->next = page; }