提交 68ca5f52 编写于 作者: H Haojun Liao

[td-225]fix memory leaks.

上级 39dc3c42
...@@ -72,6 +72,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ...@@ -72,6 +72,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// invalid file // invalid file
if (header.magic != TS_COMP_FILE_MAGIC) { if (header.magic != TS_COMP_FILE_MAGIC) {
tsBufDestroy(pTSBuf);
return NULL; return NULL;
} }
......
...@@ -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 ./tsBufTest.cpp)
TARGET_LINK_LIBRARIES(queryTest taos query gtest pthread gcov) TARGET_LINK_LIBRARIES(queryTest taos query gtest pthread gcov)
ENDIF() ENDIF()
...@@ -47,6 +47,8 @@ void simpleTest() { ...@@ -47,6 +47,8 @@ void simpleTest() {
EXPECT_EQ(pTSBuf->block.numOfElem, num); EXPECT_EQ(pTSBuf->block.numOfElem, num);
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
free(list);
} }
// one large list of ts, the ts list need to be split into several small blocks // one large list of ts, the ts list need to be split into several small blocks
...@@ -71,6 +73,7 @@ void largeTSTest() { ...@@ -71,6 +73,7 @@ void largeTSTest() {
EXPECT_EQ(pTSBuf->block.numOfElem, num); EXPECT_EQ(pTSBuf->block.numOfElem, num);
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
free(list);
} }
void multiTagsTest() { void multiTagsTest() {
...@@ -208,6 +211,8 @@ void loadDataTest() { ...@@ -208,6 +211,8 @@ void loadDataTest() {
int64_t e = taosGetTimestampUs(); int64_t e = taosGetTimestampUs();
printf("end:%" PRIu64 ", elapsed:%" PRIu64 ", total obj:%d\n", e, e - s, x); printf("end:%" PRIu64 ", elapsed:%" PRIu64 ", total obj:%d\n", e, e - s, x);
tsBufDestroy(pTSBuf);
tsBufDestroy(pNewBuf);
} }
void randomIncTsTest() {} void randomIncTsTest() {}
...@@ -338,6 +343,8 @@ void TSTraverse() { ...@@ -338,6 +343,8 @@ void TSTraverse() {
} }
} }
} }
tsBufDestroy(pTSBuf);
} }
void performanceTest() {} void performanceTest() {}
...@@ -352,9 +359,12 @@ void invalidFileTest() { ...@@ -352,9 +359,12 @@ void invalidFileTest() {
STSBuf* pNewBuf = tsBufCreateFromFile("/tmp/test", true); STSBuf* pNewBuf = tsBufCreateFromFile("/tmp/test", true);
EXPECT_TRUE(pNewBuf == NULL); EXPECT_TRUE(pNewBuf == NULL);
tsBufDestroy(pNewBuf);
pNewBuf = tsBufCreateFromFile("/tmp/911", true); pNewBuf = tsBufCreateFromFile("/tmp/911", true);
EXPECT_TRUE(pNewBuf == NULL); EXPECT_TRUE(pNewBuf == NULL);
tsBufDestroy(pNewBuf);
} }
void mergeDiffVnodeBufferTest() { void mergeDiffVnodeBufferTest() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册