X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapache.c;h=2e91a1bee3b6f4311b178e6472350496853f3ec1;hb=354f9991530248e45207d236eb74c1cc3d5238ef;hp=c515e3c5db57a45bc04e706db387d02b5a27ba24;hpb=ae5cca244ff291c17df1cc36e28f19376958a2eb;p=collectd.git diff --git a/src/apache.c b/src/apache.c index c515e3c5..2e91a1be 100644 --- a/src/apache.c +++ b/src/apache.c @@ -98,14 +98,14 @@ static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, return (0); } - if (len <= 0) + if (len == 0) return (len); if ((st->apache_buffer_fill + len) >= st->apache_buffer_size) { char *temp; - temp = (char *) realloc (st->apache_buffer, + temp = realloc (st->apache_buffer, st->apache_buffer_fill + len + 1); if (temp == NULL) { @@ -137,7 +137,7 @@ static size_t apache_header_callback (void *buf, size_t size, size_t nmemb, return (0); } - if (len <= 0) + if (len == 0) return (len); /* look for the Server header */ @@ -175,13 +175,12 @@ static int config_add (oconfig_item_t *ci) int i; int status; - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) { - ERROR ("apache plugin: malloc failed."); + ERROR ("apache plugin: calloc failed."); return (-1); } - memset (st, 0, sizeof (*st)); st->timeout = -1; @@ -255,7 +254,7 @@ static int config_add (oconfig_item_t *ci) status = plugin_register_complex_read (/* group = */ NULL, /* name = */ callback_name, /* callback = */ apache_read_host, - /* interval = */ NULL, + /* interval = */ 0, /* user_data = */ &ud); } @@ -383,8 +382,7 @@ static int init_host (apache_t *st) /* {{{ */ if (st->timeout >= 0) curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, (long) st->timeout); else - curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, - CDTIME_T_TO_MS(plugin_get_interval())); + curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, (long) CDTIME_T_TO_MS(plugin_get_interval())); #endif return (0);