From: Pavel Rochnyack Date: Wed, 11 May 2016 21:37:02 +0000 (+0600) Subject: utils_db_query: Removed excessive calls of udb_result_finish_result() and udb_query_f... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=cfef5a793e1d492ce6b6eea4c4dea60d7aa1d0e8;p=collectd.git utils_db_query: Removed excessive calls of udb_result_finish_result() and udb_query_finish_result(). --- diff --git a/src/utils_db_query.c b/src/utils_db_query.c index 0d56ad46..61fe2e41 100644 --- a/src/utils_db_query.c +++ b/src/utils_db_query.c @@ -338,22 +338,20 @@ static int udb_result_prepare_result(udb_result_t const *r, /* {{{ */ if ((r == NULL) || (prep_area == NULL)) return -EINVAL; +#if COLLECT_DEBUG + assert(prep_area->ds == NULL); + assert(prep_area->instances_pos == NULL); + assert(prep_area->values_pos == NULL); + assert(prep_area->metadata_pos == NULL); + assert(prep_area->instances_buffer == NULL); + assert(prep_area->values_buffer == NULL); + assert(prep_area->metadata_buffer == NULL); +#endif + #define BAIL_OUT(status) \ - prep_area->ds = NULL; \ - sfree(prep_area->instances_pos); \ - sfree(prep_area->values_pos); \ - sfree(prep_area->metadata_pos); \ - sfree(prep_area->instances_buffer); \ - sfree(prep_area->values_buffer); \ - sfree(prep_area->metadata_buffer); \ + udb_result_finish_result(r, prep_area); \ return (status) - /* Make sure previous preparations are cleaned up. */ - udb_result_finish_result(r, prep_area); - prep_area->instances_pos = NULL; - prep_area->values_pos = NULL; - prep_area->metadata_pos = NULL; - /* Read `ds' and check number of values {{{ */ prep_area->ds = plugin_get_ds(r->type); if (prep_area->ds == NULL) { @@ -931,7 +929,13 @@ int udb_query_prepare_result(udb_query_t const *q, /* {{{ */ if ((q == NULL) || (prep_area == NULL)) return -EINVAL; - udb_query_finish_result(q, prep_area); +#if COLLECT_DEBUG + assert(prep_area->column_num == 0); + assert(prep_area->host == NULL); + assert(prep_area->plugin == NULL); + assert(prep_area->db_name == NULL); + assert(prep_area->interval == 0); +#endif prep_area->column_num = column_num; prep_area->host = strdup(host);