X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcachec.c;h=629b99bab12dc9fa5290c3cb8bb34e87ef3d7bb5;hb=db35efb33e81d0a013e09a8a6ffa362ad5962f7c;hp=37f189468b51e7459fd1f189c22cc920d95c06cd;hpb=0beb06563c5681975fd4f743c547e15f4facb29f;p=collectd.git diff --git a/src/memcachec.c b/src/memcachec.c index 37f18946..629b99ba 100644 --- a/src/memcachec.c +++ b/src/memcachec.c @@ -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; }