[td-11818]fix memory leak.
This commit is contained in:
parent
a4aa98dafe
commit
9ef605faa0
|
@ -156,6 +156,11 @@ _exit:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void freeItemHelper(void* pItem) {
|
||||
char* p = *(char**)pItem;
|
||||
free(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pVnode
|
||||
* @param pMsg
|
||||
|
@ -169,17 +174,20 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
int32_t totalLen = 0;
|
||||
int32_t numOfTables = 0;
|
||||
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);
|
||||
totalLen += strlen(name);
|
||||
} else {
|
||||
tfree(name);
|
||||
}
|
||||
|
||||
numOfTables++;
|
||||
}
|
||||
|
||||
// TODO: temp debug, and should del when show tables command ok
|
||||
vError("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables);
|
||||
if (numOfTables > 1000) {
|
||||
numOfTables = 1000;
|
||||
vInfo("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables);
|
||||
if (numOfTables > 10000) {
|
||||
numOfTables = 10000;
|
||||
}
|
||||
|
||||
metaCloseTbCursor(pCur);
|
||||
|
@ -214,6 +222,6 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
};
|
||||
|
||||
rpcSendResponse(&rpcMsg);
|
||||
taosArrayDestroy(pArray);
|
||||
taosArrayDestroyEx(pArray, freeItemHelper);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue