From: Florian Forster Date: Sun, 2 Sep 2012 10:41:22 +0000 (+0200) Subject: memcached plugin: Replace config_set_string() with cf_util_get_string(). X-Git-Tag: collectd-5.2.0~73 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=02cb3c3e95edec5631744814196a4639b7391417;p=collectd.git memcached plugin: Replace config_set_string() with cf_util_get_string(). --- diff --git a/src/memcached.c b/src/memcached.c index b8fd9145..9dbf6675 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -261,32 +261,6 @@ static int memcached_query_daemon (char *buffer, int buffer_size, user_data_t *u * * */ -static int config_set_string (char **ret_string, oconfig_item_t *ci) -{ - char *string; - - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_STRING)) - { - WARNING ("memcached plugin: The `%s' config option " - "needs exactly one string argument.", ci->key); - return (-1); - } - - string = strdup (ci->values[0].value.string); - if (string == NULL) - { - ERROR ("memcached plugin: strdup failed."); - return (-1); - } - - if (*ret_string != NULL) - free (*ret_string); - *ret_string = string; - - return (0); -} - static int config_add_instance(oconfig_item_t *ci) { memcached_t *st; @@ -314,7 +288,7 @@ static int config_add_instance(oconfig_item_t *ci) st->port = NULL; memset (st, 0, sizeof (*st)); - status = config_set_string (&st->name, ci); + status = cf_util_get_string (ci, &st->name); if (status != 0) { sfree (st); @@ -327,11 +301,11 @@ static int config_add_instance(oconfig_item_t *ci) oconfig_item_t *child = ci->children + i; if (strcasecmp ("Socket", child->key) == 0) - status = config_set_string (&st->socket, child); + status = cf_util_get_string (child, &st->socket); else if (strcasecmp ("Host", child->key) == 0) - status = config_set_string (&st->host, child); + status = cf_util_get_string (child, &st->host); else if (strcasecmp ("Port", child->key) == 0) - status = config_set_string (&st->port, child); + status = cf_util_get_service (child, &st->port); else { WARNING ("memcached plugin: Option `%s' not allowed here.",