X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcachec.c;h=37f189468b51e7459fd1f189c22cc920d95c06cd;hb=290741f2e6de9e9b467463c1f0c6f031c4036428;hp=8f51e22f01dd3c2d728d0cbc0a8e2cc61fba99e1;hpb=4dc9287f4de0283ae986444377075dcbdada2871;p=collectd.git diff --git a/src/memcachec.c b/src/memcachec.c index 8f51e22f..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; @@ -328,7 +329,7 @@ static int cmc_config_add_page (oconfig_item_t *ci) /* {{{ */ if (strcasecmp ("Server", child->key) == 0) status = cmc_config_add_string ("Server", &page->server, child); - if (strcasecmp ("Key", child->key) == 0) + else if (strcasecmp ("Key", child->key) == 0) status = cmc_config_add_string ("Key", &page->key, child); else if (strcasecmp ("Match", child->key) == 0) /* Be liberal with failing matches => don't set `status'. */ @@ -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; } @@ -500,6 +501,7 @@ static int cmc_read_page (web_page_t *wp) /* {{{ */ } cmc_submit (wp, wm, mv); + match_value_reset (mv); } /* for (wm = wp->matches; wm != NULL; wm = wm->next) */ sfree (wp->buffer);