From 160440a8e4aef2eeb6ba44d028df4bbf9a74f39a Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 04:42:56 +0000 Subject: [PATCH] fix/TD-31891-remove-void-monitor2 --- .../monitorfw/inc/taos_metric_formatter_i.h | 2 +- .../monitorfw/inc/taos_string_builder_i.h | 2 +- source/libs/monitorfw/inc/taos_test.h | 5 ++ source/libs/monitorfw/src/taos_collector.c | 19 +++-- .../monitorfw/src/taos_collector_registry.c | 40 ++++++---- source/libs/monitorfw/src/taos_map.c | 30 +++++--- source/libs/monitorfw/src/taos_metric.c | 15 ++-- .../monitorfw/src/taos_metric_formatter.c | 20 ++--- .../src/taos_metric_formatter_custom.c | 76 +++++++++++++++---- .../libs/monitorfw/src/taos_metric_sample.c | 5 +- source/libs/monitorfw/src/taos_monitor_util.c | 4 +- .../libs/monitorfw/src/taos_string_builder.c | 9 +-- 12 files changed, 147 insertions(+), 80 deletions(-) diff --git a/source/libs/monitorfw/inc/taos_metric_formatter_i.h b/source/libs/monitorfw/inc/taos_metric_formatter_i.h index 54e683fa91..2c891dae95 100644 --- a/source/libs/monitorfw/inc/taos_metric_formatter_i.h +++ b/source/libs/monitorfw/inc/taos_metric_formatter_i.h @@ -30,7 +30,7 @@ taos_metric_formatter_t *taos_metric_formatter_new(); /** * @brief API PRIVATE taos_metric_formatter destructor */ -int taos_metric_formatter_destroy(taos_metric_formatter_t *self); +void taos_metric_formatter_destroy(taos_metric_formatter_t *self); /** * @brief API PRIVATE Loads the help text diff --git a/source/libs/monitorfw/inc/taos_string_builder_i.h b/source/libs/monitorfw/inc/taos_string_builder_i.h index 933d778691..02ca0a0900 100644 --- a/source/libs/monitorfw/inc/taos_string_builder_i.h +++ b/source/libs/monitorfw/inc/taos_string_builder_i.h @@ -31,7 +31,7 @@ taos_string_builder_t *taos_string_builder_new(void); * API PRIVATE * @brief Destroys a taos_string_builder* */ -int taos_string_builder_destroy(taos_string_builder_t *self); +void taos_string_builder_destroy(taos_string_builder_t *self); /** * API PRIVATE diff --git a/source/libs/monitorfw/inc/taos_test.h b/source/libs/monitorfw/inc/taos_test.h index b881b2cee2..11e145a7fa 100644 --- a/source/libs/monitorfw/inc/taos_test.h +++ b/source/libs/monitorfw/inc/taos_test.h @@ -23,6 +23,11 @@ if (!(i)) return 1; #define TAOS_TEST_PARA_NULL(i) \ if (!(i)) return NULL; +#define TAOS_TEST_PARA_VOID(i) \ + if (!(i)) { \ + TAOS_LOG("parameter is NULL"); \ + return; \ + } #endif // TAOS_TEST #endif // TAOS_TEST_H diff --git a/source/libs/monitorfw/src/taos_collector.c b/source/libs/monitorfw/src/taos_collector.c index 21ebb3f737..a7ea9f0f61 100644 --- a/source/libs/monitorfw/src/taos_collector.c +++ b/source/libs/monitorfw/src/taos_collector.c @@ -39,18 +39,24 @@ taos_collector_t *taos_collector_new(const char *name) { self->name = taos_strdup(name); self->metrics = taos_map_new(); if (self->metrics == NULL) { - (void)taos_collector_destroy(self); + if (taos_collector_destroy(self) != 0) { + TAOS_LOG("taos_collector_destroy failed"); + } return NULL; } r = taos_map_set_free_value_fn(self->metrics, &taos_metric_free_generic); if (r) { - (void)taos_collector_destroy(self); + if (taos_collector_destroy(self) != 0) { + TAOS_LOG("taos_collector_destroy failed"); + } return NULL; } self->collect_fn = &taos_collector_default_collect; self->string_builder = taos_string_builder_new(); if (self->string_builder == NULL) { - (void)taos_collector_destroy(self); + if (taos_collector_destroy(self) != 0) { + TAOS_LOG("taos_collector_destroy failed"); + } return NULL; } self->proc_limits_file_path = NULL; @@ -70,8 +76,7 @@ int taos_collector_destroy(taos_collector_t *self) { self->metrics = NULL; if(self->string_builder != NULL){ - r = taos_string_builder_destroy(self->string_builder); - if (r) ret = r; + taos_string_builder_destroy(self->string_builder); self->string_builder = NULL; } @@ -93,7 +98,9 @@ int taos_collector_destroy_generic(void *gen) { void taos_collector_free_generic(void *gen) { taos_collector_t *self = (taos_collector_t *)gen; - (void)taos_collector_destroy(self); + if (taos_collector_destroy(self) != 0) { + TAOS_LOG("taos_collector_destroy failed"); + } } int taos_collector_set_collect_fn(taos_collector_t *self, taos_collect_fn *fn) { diff --git a/source/libs/monitorfw/src/taos_collector_registry.c b/source/libs/monitorfw/src/taos_collector_registry.c index 94295bf9c0..bfdbf92156 100644 --- a/source/libs/monitorfw/src/taos_collector_registry.c +++ b/source/libs/monitorfw/src/taos_collector_registry.c @@ -50,7 +50,7 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) { self->name = taos_strdup(name); self->collectors = taos_map_new(); - (void)taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic); + if (taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic) != 0) return NULL; if (taos_map_set(self->collectors, "default", taos_collector_new("default")) != 0) return NULL; self->metric_formatter = taos_metric_formatter_new(); @@ -86,17 +86,14 @@ int taos_collector_registry_destroy(taos_collector_registry_t *self) { self->collectors = NULL; if (r) ret = r; - r = taos_metric_formatter_destroy(self->metric_formatter); + taos_metric_formatter_destroy(self->metric_formatter); self->metric_formatter = NULL; - if (r) ret = r; - r = taos_string_builder_destroy(self->string_builder); + taos_string_builder_destroy(self->string_builder); self->string_builder = NULL; - if (r) ret = r; - r = taos_string_builder_destroy(self->string_builder_batch); + taos_string_builder_destroy(self->string_builder_batch); self->string_builder_batch = NULL; - if (r) ret = r; r = pthread_rwlock_destroy(self->lock); taos_free(self->lock); @@ -241,13 +238,25 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, SJson* pJson = tjsonCreateArray(); SJson* item = tjsonCreateObject(); - (void)tjsonAddItemToArray(pJson, item); - (void)tjsonAddStringToObject(item, "ts", ts); - (void)tjsonAddDoubleToObject(item, "protocol", 2); - SJson* array = tjsonCreateArray(); - (void)tjsonAddItemToObject(item, "tables", array); + if (tjsonAddItemToArray(pJson, item) != 0) { + tjsonDelete(pJson); + return NULL; + } + if (tjsonAddStringToObject(item, "ts", ts) != 0) { + tjsonDelete(pJson); + return NULL; + } + if (tjsonAddDoubleToObject(item, "protocol", 2) != 0) { + tjsonDelete(pJson); + return NULL; + } + SJson *array = tjsonCreateArray(); + if (tjsonAddItemToObject(item, "tables", array) != 0) { + tjsonDelete(pJson); + return NULL; + } - if(taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array) != 0){ + if (taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array) != 0) { TAOS_LOG("failed to load metrics"); tjsonDelete(pJson); return NULL; @@ -294,9 +303,8 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, r = taos_string_builder_clear(tmp_builder); if (r) goto _OVER;; - r = taos_string_builder_destroy(tmp_builder); + taos_string_builder_destroy(tmp_builder); tmp_builder = NULL; - if (r) goto _OVER;; tjsonDelete(pJson); return data; @@ -304,7 +312,7 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, _OVER: tjsonDelete(pJson); if(tmp_builder != NULL){ - (void)taos_string_builder_destroy(tmp_builder); + taos_string_builder_destroy(tmp_builder); } return NULL; diff --git a/source/libs/monitorfw/src/taos_map.c b/source/libs/monitorfw/src/taos_map.c index 2f5bf566c2..bf1b85c534 100644 --- a/source/libs/monitorfw/src/taos_map.c +++ b/source/libs/monitorfw/src/taos_map.c @@ -45,21 +45,19 @@ taos_map_node_t *taos_map_node_new(const char *key, void *value, taos_map_node_f return self; } -int taos_map_node_destroy(taos_map_node_t *self) { - TAOS_TEST_PARA(self != NULL); - if (self == NULL) return 0; +void taos_map_node_destroy(taos_map_node_t *self) { + TAOS_TEST_PARA_VOID(self != NULL); taos_free((void *)self->key); self->key = NULL; if (self->value != NULL) (*self->free_value_fn)(self->value); self->value = NULL; taos_free(self); self = NULL; - return 0; } void taos_map_node_free(void *item) { taos_map_node_t *map_node = (taos_map_node_t *)item; - (void)taos_map_node_destroy(map_node); + taos_map_node_destroy(map_node); } taos_linked_list_compare_t taos_map_node_compare(void *item_a, void *item_b) { @@ -87,7 +85,9 @@ taos_map_t *taos_map_new() { // we will only have to deallocate each key once. That will happen on taos_map_node_destroy. r = taos_linked_list_set_free_fn(self->keys, taos_linked_list_no_op_free); if (r) { - (void)taos_map_destroy(self); + if (taos_map_destroy(self) != 0) { + TAOS_LOG("TAOS_MAP_DESTROY_ERROR"); + } return NULL; } @@ -98,12 +98,16 @@ taos_map_t *taos_map_new() { self->addrs[i] = taos_linked_list_new(); r = taos_linked_list_set_free_fn(self->addrs[i], taos_map_node_free); if (r) { - (void)taos_map_destroy(self); + if (taos_map_destroy(self) != 0) { + TAOS_LOG("TAOS_MAP_DESTROY_ERROR"); + } return NULL; } r = taos_linked_list_set_compare_fn(self->addrs[i], taos_map_node_compare); if (r) { - (void)taos_map_destroy(self); + if (taos_map_destroy(self) != 0) { + TAOS_LOG("TAOS_MAP_DESTROY_ERROR"); + } return NULL; } } @@ -112,7 +116,9 @@ taos_map_t *taos_map_new() { r = pthread_rwlock_init(self->rwlock, NULL); if (r) { TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR); - (void)taos_map_destroy(self); + if (taos_map_destroy(self) != 0) { + TAOS_LOG("TAOS_MAP_DESTROY_ERROR"); + } return NULL; } @@ -188,12 +194,12 @@ static void *taos_map_get_internal(const char *key, size_t *size, size_t *max_si taos_map_node_t *current_map_node = (taos_map_node_t *)current_node->item; taos_linked_list_compare_t result = taos_linked_list_compare(list, current_map_node, temp_map_node); if (result == TAOS_EQUAL) { - (void)taos_map_node_destroy(temp_map_node); + taos_map_node_destroy(temp_map_node); temp_map_node = NULL; return current_map_node->value; } } - (void)taos_map_node_destroy(temp_map_node); + taos_map_node_destroy(temp_map_node); temp_map_node = NULL; return NULL; } @@ -388,7 +394,7 @@ static int taos_map_delete_internal(const char *key, size_t *size, size_t *max_s break; } } - r = taos_map_node_destroy(temp_map_node); + taos_map_node_destroy(temp_map_node); temp_map_node = NULL; return r; } diff --git a/source/libs/monitorfw/src/taos_metric.c b/source/libs/monitorfw/src/taos_metric.c index 42564437d0..9d55680c4d 100644 --- a/source/libs/monitorfw/src/taos_metric.c +++ b/source/libs/monitorfw/src/taos_metric.c @@ -49,12 +49,12 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, for (int i = 0; i < label_key_count; i++) { if (strcmp(label_keys[i], "le") == 0) { TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); - (void)taos_metric_destroy(self); + if (taos_metric_destroy(self) != 0) return NULL; return NULL; } if (strcmp(label_keys[i], "quantile") == 0) { TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); - (void)taos_metric_destroy(self); + if (taos_metric_destroy(self) != 0) return NULL; return NULL; } k[i] = taos_strdup(label_keys[i]); @@ -68,14 +68,14 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, } else { r = taos_map_set_free_value_fn(self->samples, &taos_metric_sample_free_generic); if (r) { - (void)taos_metric_destroy(self); + if (taos_metric_destroy(self) != 0) return NULL; return NULL; } } self->formatter = taos_metric_formatter_new(); if (self->formatter == NULL) { - (void)taos_metric_destroy(self); + if (taos_metric_destroy(self) != 0) return NULL; return NULL; } self->rwlock = (pthread_rwlock_t *)taos_malloc(sizeof(pthread_rwlock_t)); @@ -101,9 +101,8 @@ int taos_metric_destroy(taos_metric_t *self) { if (r) ret = r; } - r = taos_metric_formatter_destroy(self->formatter); + taos_metric_formatter_destroy(self->formatter); self->formatter = NULL; - if (r) ret = r; r = pthread_rwlock_destroy(self->rwlock); if (r) { @@ -140,7 +139,9 @@ int taos_metric_destroy_generic(void *item) { void taos_metric_free_generic(void *item) { taos_metric_t *self = (taos_metric_t *)item; - (void)taos_metric_destroy(self); + if (taos_metric_destroy(self) != 0) { + TAOS_LOG("taos_metric_destroy failed"); + } } taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const char **label_values) { diff --git a/source/libs/monitorfw/src/taos_metric_formatter.c b/source/libs/monitorfw/src/taos_metric_formatter.c index cb1edd30b6..31796c20df 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter.c +++ b/source/libs/monitorfw/src/taos_metric_formatter.c @@ -22,6 +22,7 @@ // Private #include "taos_collector_t.h" #include "taos_linked_list_t.h" +#include "taos_log.h" #include "taos_map_i.h" #include "taos_metric_formatter_i.h" #include "taos_metric_sample_t.h" @@ -33,35 +34,28 @@ taos_metric_formatter_t *taos_metric_formatter_new() { taos_metric_formatter_t *self = (taos_metric_formatter_t *)taos_malloc(sizeof(taos_metric_formatter_t)); self->string_builder = taos_string_builder_new(); if (self->string_builder == NULL) { - (void)taos_metric_formatter_destroy(self); + taos_metric_formatter_destroy(self); return NULL; } self->err_builder = taos_string_builder_new(); if (self->err_builder == NULL) { - (void)taos_metric_formatter_destroy(self); + taos_metric_formatter_destroy(self); return NULL; } return self; } -int taos_metric_formatter_destroy(taos_metric_formatter_t *self) { - TAOS_TEST_PARA(self != NULL); - if (self == NULL) return 0; +void taos_metric_formatter_destroy(taos_metric_formatter_t *self) { + TAOS_TEST_PARA_VOID(self != NULL); - int r = 0; - int ret = 0; - - r = taos_string_builder_destroy(self->string_builder); + taos_string_builder_destroy(self->string_builder); self->string_builder = NULL; - if (r) ret = r; - r = taos_string_builder_destroy(self->err_builder); + taos_string_builder_destroy(self->err_builder); self->err_builder = NULL; - if (r) ret = r; taos_free(self); self = NULL; - return ret; } /* int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *name, const char *help) { diff --git a/source/libs/monitorfw/src/taos_metric_formatter_custom.c b/source/libs/monitorfw/src/taos_metric_formatter_custom.c index da05d09d9c..82d46d4426 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter_custom.c +++ b/source/libs/monitorfw/src/taos_metric_formatter_custom.c @@ -88,17 +88,47 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me char* value = *(pair + 1); SJson* tag = tjsonCreateObject(); - (void)tjsonAddStringToObject(tag, "name", key); - (void)tjsonAddStringToObject(tag, "value", value); + if (tjsonAddStringToObject(tag, "name", key) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; + } + if (tjsonAddStringToObject(tag, "value", value) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; + } - (void)tjsonAddItemToArray(arrayTag, tag); + if (tjsonAddItemToArray(arrayTag, tag) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; + } + } + if (tjsonAddItemToObject(item, "tags", arrayTag) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; } - (void)tjsonAddItemToObject(item, "tags", arrayTag); metrics = tjsonCreateArray(); - (void)tjsonAddItemToObject(item, "metrics", metrics); + if (tjsonAddItemToObject(item, "metrics", metrics) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; + } - (void)tjsonAddItemToArray(arrayMetricGroups, item); + if (tjsonAddItemToArray(arrayMetricGroups, item) != 0) { + taosMemoryFreeClear(arr); + taosMemoryFreeClear(keyvalue); + taosMemoryFreeClear(keyvalues); + return 1; + } } else{ metrics = tjsonGetObjectItem(item, "metrics"); @@ -109,20 +139,20 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me taosMemoryFreeClear(keyvalues); SJson* metric = tjsonCreateObject(); - (void)tjsonAddStringToObject(metric, "name", metricName); + if (tjsonAddStringToObject(metric, "name", metricName) != 0) return 1; double old_value = 0; #define USE_EXCHANGE #ifdef USE_EXCHANGE - (void)taos_metric_sample_exchange(sample, 0, &old_value); + if (taos_metric_sample_exchange(sample, 0, &old_value) != 0) return 1; #else old_value = sample->r_value; taos_metric_sample_set(sample, 0); #endif - (void)tjsonAddDoubleToObject(metric, "value", old_value); - (void)tjsonAddDoubleToObject(metric, "type", metric_type); - (void)tjsonAddItemToArray(metrics, metric); + if (tjsonAddDoubleToObject(metric, "value", old_value) != 0) return 1; + if (tjsonAddDoubleToObject(metric, "type", metric_type) != 0) return 1; + if (tjsonAddItemToArray(metrics, metric) != 0) return 1; return 0; } @@ -150,7 +180,11 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me SJson* table = tjsonGetArrayItem(tableArray, i); char tableName[MONITOR_TABLENAME_LEN] = {0}; - (void)tjsonGetStringValue(table, "name", tableName); + r = tjsonGetStringValue(table, "name", tableName); + if (r) { + taosMemoryFreeClear(name); + return r; + } if(strcmp(tableName, arr[0]) == 0){ isFound = true; arrayMetricGroups = tjsonGetObjectItem(table, "metric_groups"); @@ -161,10 +195,18 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me if(!isFound){ table = tjsonCreateObject(); - (void)tjsonAddStringToObject(table, "name", arr[0]); + r = tjsonAddStringToObject(table, "name", arr[0]); + if (r) { + taosMemoryFreeClear(name); + return r; + } arrayMetricGroups = tjsonCreateArray(); - (void)tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups); + r = tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups); + if (r) { + taosMemoryFreeClear(name); + return r; + } } int32_t sample_count = 0; @@ -183,7 +225,11 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me } if(!isFound && sample_count > 0){ - (void)tjsonAddItemToArray(tableArray, table); + r = tjsonAddItemToArray(tableArray, table); + if (r) { + taosMemoryFreeClear(name); + return r; + } } else{ if(table != NULL) tjsonDelete(table); diff --git a/source/libs/monitorfw/src/taos_metric_sample.c b/source/libs/monitorfw/src/taos_metric_sample.c index e4b41d5475..ca41cf1a83 100644 --- a/source/libs/monitorfw/src/taos_metric_sample.c +++ b/source/libs/monitorfw/src/taos_metric_sample.c @@ -44,7 +44,6 @@ taos_metric_sample_t *taos_metric_sample_new(taos_metric_type_t type, const char int taos_metric_sample_destroy(taos_metric_sample_t *self) { TAOS_TEST_PARA(self != NULL); - if (self == NULL) return 0; taos_free((void *)self->l_value); self->l_value = NULL; taos_free((void *)self); @@ -63,7 +62,9 @@ int taos_metric_sample_destroy_generic(void *gen) { void taos_metric_sample_free_generic(void *gen) { taos_metric_sample_t *self = (taos_metric_sample_t *)gen; - (void)taos_metric_sample_destroy(self); + if(taos_metric_sample_destroy(self) != 0) { + TAOS_LOG(TAOS_METRIC_SAMPLE_DESTROY_ERROR); + } } int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) { diff --git a/source/libs/monitorfw/src/taos_monitor_util.c b/source/libs/monitorfw/src/taos_monitor_util.c index 2285ed9e71..06ae4993c5 100644 --- a/source/libs/monitorfw/src/taos_monitor_util.c +++ b/source/libs/monitorfw/src/taos_monitor_util.c @@ -84,10 +84,10 @@ bool taos_monitor_is_match(const SJson* tags, char** pairs, int32_t count) { SJson* item = tjsonGetArrayItem(tags, i); char item_name[MONITOR_TAG_NAME_LEN] = {0}; - (void)tjsonGetStringValue(item, "name", item_name); + if (tjsonGetStringValue(item, "name", item_name) != 0) return false; char item_value[MONITOR_TAG_VALUE_LEN] = {0}; - (void)tjsonGetStringValue(item, "value", item_value); + if (tjsonGetStringValue(item, "value", item_value) != 0) return false; bool isfound = false; for(int32_t j = 0; j < count; j++){ diff --git a/source/libs/monitorfw/src/taos_string_builder.c b/source/libs/monitorfw/src/taos_string_builder.c index 6e3fe1d2e3..b1a5a098bc 100644 --- a/source/libs/monitorfw/src/taos_string_builder.c +++ b/source/libs/monitorfw/src/taos_string_builder.c @@ -20,6 +20,7 @@ #include "taos_alloc.h" // Private +#include "taos_log.h" #include "taos_string_builder_i.h" #include "taos_string_builder_t.h" #include "taos_test.h" @@ -44,7 +45,7 @@ taos_string_builder_t *taos_string_builder_new(void) { self->init_size = TAOS_STRING_BUILDER_INIT_SIZE; r = taos_string_builder_init(self); if (r) { - (void)taos_string_builder_destroy(self); + taos_string_builder_destroy(self); return NULL; } @@ -61,14 +62,12 @@ int taos_string_builder_init(taos_string_builder_t *self) { return 0; } -int taos_string_builder_destroy(taos_string_builder_t *self) { - TAOS_TEST_PARA(self != NULL); - if (self == NULL) return 0; +void taos_string_builder_destroy(taos_string_builder_t *self) { + TAOS_TEST_PARA_VOID(self != NULL); taos_free(self->str); self->str = NULL; taos_free(self); self = NULL; - return 0; } /**