提交 9ef605fa 编写于 作者: H Haojun Liao

[td-11818]fix memory leak.

上级 a4aa98da
...@@ -156,6 +156,11 @@ _exit: ...@@ -156,6 +156,11 @@ _exit:
return 0; return 0;
} }
static void freeItemHelper(void* pItem) {
char* p = *(char**)pItem;
free(p);
}
/** /**
* @param pVnode * @param pVnode
* @param pMsg * @param pMsg
...@@ -169,17 +174,20 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { ...@@ -169,17 +174,20 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
int32_t totalLen = 0; int32_t totalLen = 0;
int32_t numOfTables = 0; int32_t numOfTables = 0;
while ((name = metaTbCursorNext(pCur)) != NULL) { while ((name = metaTbCursorNext(pCur)) != NULL) {
if (numOfTables < 1000) { // TODO: temp get tables of vnode, and should del when show tables commad ok. if (numOfTables < 10000) { // TODO: temp get tables of vnode, and should del when show tables commad ok.
taosArrayPush(pArray, &name); taosArrayPush(pArray, &name);
totalLen += strlen(name); totalLen += strlen(name);
} else {
tfree(name);
} }
numOfTables++; numOfTables++;
} }
// TODO: temp debug, and should del when show tables command ok // TODO: temp debug, and should del when show tables command ok
vError("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables); vInfo("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables);
if (numOfTables > 1000) { if (numOfTables > 10000) {
numOfTables = 1000; numOfTables = 10000;
} }
metaCloseTbCursor(pCur); metaCloseTbCursor(pCur);
...@@ -214,6 +222,6 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { ...@@ -214,6 +222,6 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
}; };
rpcSendResponse(&rpcMsg); rpcSendResponse(&rpcMsg);
taosArrayDestroy(pArray); taosArrayDestroyEx(pArray, freeItemHelper);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册