fix memory leak

This commit is contained in:
Hongze Cheng 2022-01-24 06:44:19 +00:00
parent c19e7779df
commit 03c19aa887
4 changed files with 20 additions and 6 deletions

View File

@ -587,9 +587,10 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
pBuf = value.data;
metaDecodeTbInfo(pBuf, &tbCfg);
if (tbCfg.type == META_SUPER_TABLE) {
free(tbCfg.stbCfg.pTagSchema);
continue;
} else if (tbCfg.type == META_CHILD_TABLE) {
kvRowFree(tbCfg.ctbCfg.pTag)
kvRowFree(tbCfg.ctbCfg.pTag);
}
return tbCfg.name;
} else {

View File

@ -81,6 +81,9 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pMeta, STqCfg* tqConfig, SMemAl
}
void tqClose(STQ* pTq) {
if (pTq) {
free(pTq);
}
// TODO
}

View File

@ -114,4 +114,3 @@ static void vArenaNodeFree(SVArenaNode *pNode) {
if (pNode) {
free(pNode);
}
}

View File

@ -145,9 +145,15 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
_exit:
free(pSW->pSchema);
free(pSW);
free(pTbCfg->name);
free(pTbCfg);
if (pTbCfg->type == META_SUPER_TABLE) {
free(pTbCfg->stbCfg.pTagSchema);
} else if (pTbCfg->type == META_SUPER_TABLE) {
kvRowFree(pTbCfg->ctbCfg.pTag);
}
rpcMsg.handle = pMsg->handle;
rpcMsg.ahandle = pMsg->ahandle;
rpcMsg.pCont = pTbMetaMsg;
@ -159,8 +165,8 @@ _exit:
return 0;
}
static void freeItemHelper(void* pItem) {
char* p = *(char**)pItem;
static void freeItemHelper(void *pItem) {
char *p = *(char **)pItem;
free(p);
}
@ -190,14 +196,14 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
// TODO: temp debug, and should del when show tables command ok
vInfo("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables);
if (numOfTables > 10000) {
numOfTables = 10000;
numOfTables = 10000;
}
metaCloseTbCursor(pCur);
int32_t rowLen =
(TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 2 + (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 4;
//int32_t numOfTables = (int32_t)taosArrayGetSize(pArray);
// int32_t numOfTables = (int32_t)taosArrayGetSize(pArray);
int32_t payloadLen = rowLen * numOfTables;
// SVShowTablesFetchReq *pFetchReq = pMsg->pCont;
@ -225,6 +231,11 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
};
rpcSendResponse(&rpcMsg);
for (int i = 0; i < taosArrayGetSize(pArray); i++) {
name = *(char **)taosArrayGet(pArray, i);
free(name);
}
taosArrayDestroyEx(pArray, freeItemHelper);
return 0;
}