X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcached.c;h=d7578b625c8a1d7db08aa4f69a19af48f708a598;hb=7b64cc91d3307179557b25b6ece2349a088f4294;hp=e2ccfee6ae72ae006ed7f539a2f526161aaba7bc;hpb=eea01a8f212634414a21462ba79dc058dc5fb304;p=collectd.git diff --git a/src/memcached.c b/src/memcached.c index e2ccfee6..62ac72a8 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -34,7 +34,6 @@ #include "configfile.h" #include -#include #include #include #include @@ -62,6 +61,7 @@ static void memcached_free (memcached_t *st) sfree (st->socket); sfree (st->host); sfree (st->port); + sfree (st); } static int memcached_connect_unix (memcached_t *st) @@ -98,8 +98,8 @@ static int memcached_connect_unix (memcached_t *st) static int memcached_connect_inet (memcached_t *st) { - char *host; - char *port; + const char *host; + const char *port; struct addrinfo ai_hints; struct addrinfo *ai_list, *ai_ptr; @@ -173,8 +173,7 @@ static int memcached_connect (memcached_t *st) static int memcached_query_daemon (char *buffer, size_t buffer_size, memcached_t *st) { - int fd = -1; - int status; + int fd, status; size_t buffer_fill; fd = memcached_connect (st); @@ -439,7 +438,7 @@ static int memcached_read (user_data_t *user_data) } else if (FIELD_IS ("listen_disabled_num")) { - submit_derive ("memcached_connections", "listen_disabled", atof (fields[2]), st); + submit_derive ("connections", "listen_disabled", atof (fields[2]), st); } /* @@ -565,7 +564,7 @@ static int memcached_add_read_callback (memcached_t *st) status = plugin_register_complex_read (/* group = */ "memcached", /* name = */ callback_name, /* callback = */ memcached_read, - /* interval = */ NULL, + /* interval = */ 0, /* user_data = */ &ud); return (status); } /* int memcached_add_read_callback */ @@ -587,14 +586,13 @@ static int config_add_instance(oconfig_item_t *ci) /* Disable automatic generation of default instance in the init callback. */ memcached_have_instances = 1; - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) { - ERROR ("memcached plugin: malloc failed."); + ERROR ("memcached plugin: calloc failed."); return (-1); } - memset (st, 0, sizeof (*st)); st->name = NULL; st->socket = NULL; st->host = NULL; @@ -685,10 +683,9 @@ static int memcached_init (void) return (0); /* No instances were configured, lets start a default instance. */ - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) return (ENOMEM); - memset (st, 0, sizeof (*st)); st->name = sstrdup ("__legacy__"); st->socket = NULL; st->host = NULL;