From b537bf318b028eb708e63d2ee25f11c67d7c61a6 Mon Sep 17 00:00:00 2001 From: freemine Date: Thu, 29 Dec 2022 10:36:34 +0800 Subject: [PATCH] new API taos_stmt_reclaim_fields to reclaim TAOS_FIELD_E in a uniform way --- include/client/taos.h | 2 ++ source/client/src/clientMain.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/client/taos.h b/include/client/taos.h index 647f906d4f..e54300e33e 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -161,6 +161,8 @@ DLL_EXPORT int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name); DLL_EXPORT int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); DLL_EXPORT int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields); DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 87f5e5fa40..e37ed4c1bc 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1331,6 +1331,14 @@ int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fiel return stmtGetColFields(stmt, fieldNum, fields); } +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields) +{ + (void)stmt; + if (!fields) return; + taosMemoryFree(fields); +} + int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { if (stmt == NULL || bind == NULL) { tscError("NULL parameter for %s", __FUNCTION__); -- GitLab