提交 03c19aa8 编写于 作者: H Hongze Cheng

fix memory leak

上级 c19e7779
...@@ -587,9 +587,10 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) { ...@@ -587,9 +587,10 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
pBuf = value.data; pBuf = value.data;
metaDecodeTbInfo(pBuf, &tbCfg); metaDecodeTbInfo(pBuf, &tbCfg);
if (tbCfg.type == META_SUPER_TABLE) { if (tbCfg.type == META_SUPER_TABLE) {
free(tbCfg.stbCfg.pTagSchema);
continue; continue;
} else if (tbCfg.type == META_CHILD_TABLE) { } else if (tbCfg.type == META_CHILD_TABLE) {
kvRowFree(tbCfg.ctbCfg.pTag) kvRowFree(tbCfg.ctbCfg.pTag);
} }
return tbCfg.name; return tbCfg.name;
} else { } else {
......
...@@ -81,6 +81,9 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pMeta, STqCfg* tqConfig, SMemAl ...@@ -81,6 +81,9 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pMeta, STqCfg* tqConfig, SMemAl
} }
void tqClose(STQ* pTq) { void tqClose(STQ* pTq) {
if (pTq) {
free(pTq);
}
// TODO // TODO
} }
......
...@@ -114,4 +114,3 @@ static void vArenaNodeFree(SVArenaNode *pNode) { ...@@ -114,4 +114,3 @@ static void vArenaNodeFree(SVArenaNode *pNode) {
if (pNode) { if (pNode) {
free(pNode); free(pNode);
} }
}
\ No newline at end of file
...@@ -145,9 +145,15 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { ...@@ -145,9 +145,15 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
_exit: _exit:
free(pSW->pSchema);
free(pSW); free(pSW);
free(pTbCfg->name); free(pTbCfg->name);
free(pTbCfg); 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.handle = pMsg->handle;
rpcMsg.ahandle = pMsg->ahandle; rpcMsg.ahandle = pMsg->ahandle;
rpcMsg.pCont = pTbMetaMsg; rpcMsg.pCont = pTbMetaMsg;
...@@ -159,8 +165,8 @@ _exit: ...@@ -159,8 +165,8 @@ _exit:
return 0; return 0;
} }
static void freeItemHelper(void* pItem) { static void freeItemHelper(void *pItem) {
char* p = *(char**)pItem; char *p = *(char **)pItem;
free(p); free(p);
} }
...@@ -197,7 +203,7 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { ...@@ -197,7 +203,7 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
int32_t rowLen = int32_t rowLen =
(TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 2 + (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 4; (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; int32_t payloadLen = rowLen * numOfTables;
// SVShowTablesFetchReq *pFetchReq = pMsg->pCont; // SVShowTablesFetchReq *pFetchReq = pMsg->pCont;
...@@ -225,6 +231,11 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { ...@@ -225,6 +231,11 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
}; };
rpcSendResponse(&rpcMsg); rpcSendResponse(&rpcMsg);
for (int i = 0; i < taosArrayGetSize(pArray); i++) {
name = *(char **)taosArrayGet(pArray, i);
free(name);
}
taosArrayDestroyEx(pArray, freeItemHelper); taosArrayDestroyEx(pArray, freeItemHelper);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册