X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcachec.c;h=55e9b855b8ff2ceb6a4432e3e4390e1125d0454d;hb=58c91485b9b28a866715fc013d23236470699940;hp=c57a831226d4da64691922a7a43983c5b37eeee1;hpb=d6021a800b12c89b5a78877af2c5b9abc1a8e609;p=collectd.git diff --git a/src/memcachec.c b/src/memcachec.c index c57a8312..55e9b855 100644 --- a/src/memcachec.c +++ b/src/memcachec.c @@ -18,10 +18,11 @@ * * Authors: * Doug MacEachern - * Florian octo Forster + * Florian octo Forster **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" @@ -206,13 +207,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,13 +263,16 @@ 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); if (match->match == NULL) { - ERROR ("memcachec plugin: tail_match_add_match_simple failed."); + ERROR ("memcachec plugin: match_create_simple failed."); cmc_web_match_free (match); return (-1); } @@ -302,13 +305,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 +388,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 +502,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);