[td-11818]fix memory leak.
This commit is contained in:
parent
a4aa98dafe
commit
9ef605faa0
|
@ -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) {
|
||||||
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) {
|
||||||
};
|
};
|
||||||
|
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroyEx(pArray, freeItemHelper);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue