From a1afea4066fd96e97ef28076f67daa5fcc410369 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 16 May 2022 10:28:20 +0800 Subject: [PATCH] refactor:fix memory leak --- source/libs/parser/src/parInsert.c | 13 +------------ source/libs/parser/src/parInsertData.c | 4 +--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 15e4b8ef36..ce2ceb9af5 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1041,18 +1041,6 @@ static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) { destroyCreateSubTbReq(&pCxt->createTblReq); } -static void destroyDataBlock(STableDataBlocks* pDataBlock) { - if (pDataBlock == NULL) { - return; - } - - taosMemoryFreeClear(pDataBlock->pData); - if (!pDataBlock->cloned) { - destroyBoundColumnInfo(&pDataBlock->boundColumnInfo); - } - taosMemoryFreeClear(pDataBlock); -} - static void destroyInsertParseContext(SInsertParseContext* pCxt) { destroyInsertParseContextForTable(pCxt); taosHashCleanup(pCxt->pVgroupsHashObj); @@ -1301,6 +1289,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash CHECK_CODE(buildOutput(&insertCtx)); + destroyInsertParseContext(&insertCtx); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index 8b649350b7..deb899309e 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -237,9 +237,7 @@ static void destroyDataBlock(STableDataBlocks* pDataBlock) { taosMemoryFreeClear(pDataBlock->pData); if (!pDataBlock->cloned) { // free the refcount for metermeta - if (pDataBlock->pTableMeta != NULL) { - taosMemoryFreeClear(pDataBlock->pTableMeta); - } + taosMemoryFreeClear(pDataBlock->pTableMeta); destroyBoundColumnInfo(&pDataBlock->boundColumnInfo); } -- GitLab