提交 8e97949a 编写于 作者: H Haojun Liao

[td-225] fix memory leaks.

上级 9a9ea692
......@@ -184,7 +184,10 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32
pResultBuf->inMemPages, pResultBuf->pageSize);
} else {
tdListPopNode(pResultBuf->pPageList, pn);
if (flushPageToDisk(pResultBuf, *(SPageInfo**)pn->data) != TSDB_CODE_SUCCESS) {
SPageInfo* d = *(SPageInfo**) pn->data;
tfree(pn);
if (flushPageToDisk(pResultBuf, d) != TSDB_CODE_SUCCESS) {
return NULL;
}
}
......@@ -275,6 +278,8 @@ tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) {
fread(buf, (*pi)->info.length, 1, pResultBuf->file);
(*pi)->pData = buf;
tfree(pn);
return (*pi)->pData;
}
}
......@@ -292,7 +297,6 @@ void releaseResBufPage(SDiskbasedResultBuf* pResultBuf, void* page) {
T_REF_DEC(ppi);
}
int32_t getNumOfRowsPerPage(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->numOfRowsPerPage; }
SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
......@@ -325,15 +329,18 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
unlink(pResultBuf->path);
tfree(pResultBuf->path);
// size_t size = taosArrayGetSize(pResultBuf->list);
// for (int32_t i = 0; i < size; ++i) {
// SArray* pa = taosArrayGetP(pResultBuf->list, i);
// taosArrayDestroy(pa);
// }
SHashMutableIterator* iter = taosHashCreateIter(pResultBuf->idsTable);
while(taosHashIterNext(iter)) {
SArray** p = (SArray**) taosHashIterGet(iter);
taosArrayDestroy(*p);
}
taosHashDestroyIter(iter);
tdListFree(pResultBuf->pPageList);
taosArrayDestroy(pResultBuf->emptyDummyIdList);
taosHashCleanup(pResultBuf->idsTable);
taosHashCleanup(pResultBuf->all);
tfree(pResultBuf);
}
......
......@@ -10,6 +10,6 @@ IF (HEADER_GTEST_INCLUDE_DIR AND LIB_GTEST_STATIC_DIR)
INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR})
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE(queryTest ${SOURCE_LIST})
ADD_EXECUTABLE(queryTest ./unitTest.cpp ./resultBufferTest.cpp)
TARGET_LINK_LIBRARIES(queryTest taos query gtest pthread)
ENDIF()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册