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

[td-225] fix memory leaks.

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