From e0167511c1a2c10f9c06c1c6a7ac4d17ed441adb Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao> Date: Fri, 31 May 2024 17:18:25 +0800 Subject: [PATCH] use tDeleteSVCreateTbBatchReq free mem --- source/client/src/clientRawBlockWrite.c | 17 ++--------------- source/common/src/tmsg.c | 7 +++++-- source/dnode/vnode/src/tq/tqRead.c | 9 +-------- source/dnode/vnode/src/vnd/vnodeSvr.c | 7 +------ 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index 5e6d693562..d8bd56985f 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -440,14 +440,7 @@ static cJSON* processCreateTable(SMqMetaRsp* metaRsp) { _exit: uDebug("create table return, sql json:%s", cJSON_PrintUnformatted(pJson)); - for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { - pCreateReq = req.pReqs + iReq; - taosMemoryFreeClear(pCreateReq->comment); - taosMemoryFreeClear(pCreateReq->sql); - if (pCreateReq->type == TSDB_CHILD_TABLE) { - taosArrayDestroy(pCreateReq->ctb.tagName); - } - } + tDeleteSVCreateTbBatchReq(&req); tDecoderClear(&decoder); return pJson; } @@ -1110,13 +1103,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { end: uDebug(LOG_ID_TAG " create table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); - for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { - pCreateReq = req.pReqs + iReq; - taosMemoryFreeClear(pCreateReq->comment); - if (pCreateReq->type == TSDB_CHILD_TABLE) { - taosArrayDestroy(pCreateReq->ctb.tagName); - } - } + tDeleteSVCreateTbBatchReq(&req); taosHashCleanup(pVgroupHashmap); destroyRequest(pRequest); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c17c522d4f..6bb88b7824 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -8369,11 +8369,14 @@ int tDecodeSVCreateTbBatchReq(SDecoder *pCoder, SVCreateTbBatchReq *pReq) { return 0; } -void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq* pReq) { +void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq *pReq) { for (int32_t iReq = 0; iReq < pReq->nReqs; iReq++) { - SVCreateTbReq* pCreateReq = pReq->pReqs + iReq; + SVCreateTbReq *pCreateReq = pReq->pReqs + iReq; + taosMemoryFreeClear(pCreateReq->sql); + taosMemoryFreeClear(pCreateReq->comment); if (pCreateReq->type == TSDB_CHILD_TABLE) { taosArrayDestroy(pCreateReq->ctb.tagName); + pCreateReq->ctb.tagName = NULL; } } } diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 9cbe48a0b0..40b817accd 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -99,14 +99,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) { taosArrayDestroy(reqNew.pArray); } - for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { - pCreateReq = req.pReqs + iReq; - taosMemoryFreeClear(pCreateReq->comment); - taosMemoryFreeClear(pCreateReq->sql); - if (pCreateReq->type == TSDB_CHILD_TABLE) { - taosArrayDestroy(pCreateReq->ctb.tagName); - } - } + tDeleteSVCreateTbBatchReq(&req); } else if (msgType == TDMT_VND_ALTER_TABLE) { SVAlterTbReq req = {0}; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index cb71495e9f..3a3109862c 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1158,12 +1158,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, } _exit: - for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { - pCreateReq = req.pReqs + iReq; - taosMemoryFree(pCreateReq->sql); - taosMemoryFree(pCreateReq->comment); - taosArrayDestroy(pCreateReq->ctb.tagName); - } + tDeleteSVCreateTbBatchReq(&req); taosArrayDestroyEx(rsp.pArray, tFreeSVCreateTbRsp); taosArrayDestroy(tbUids); tDecoderClear(&decoder);