From dfe2c4fc67756167c13cfebe0de4ca515e1514b8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 20 Jul 2020 17:16:59 +0800 Subject: [PATCH] [td-225] fix memory leaks. --- src/query/inc/qResultbuf.h | 1 + src/query/src/qResultbuf.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/query/inc/qResultbuf.h b/src/query/inc/qResultbuf.h index d76659cc91..8c8afb0957 100644 --- a/src/query/inc/qResultbuf.h +++ b/src/query/inc/qResultbuf.h @@ -42,6 +42,7 @@ typedef struct SDiskbasedResultBuf { void* iBuf; // inmemory buf void* handle; // for debug purpose + void* emptyDummyIdList; // dummy id list } SDiskbasedResultBuf; #define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) diff --git a/src/query/src/qResultbuf.c b/src/query/src/qResultbuf.c index 0eefb106b9..de59676e59 100644 --- a/src/query/src/qResultbuf.c +++ b/src/query/src/qResultbuf.c @@ -36,6 +36,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t nu pResBuf->fd = FD_INITIALIZER; pResBuf->pBuf = NULL; + pResBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t)); qDebug("QInfo:%p create resBuf for output, page size:%d, initial pages:%d, %" PRId64 "bytes", handle, pResBuf->pageSize, pResBuf->numOfPages, pResBuf->totalBufSize); @@ -173,7 +174,7 @@ int32_t getNumOfRowsPerPage(SDiskbasedResultBuf* pResultBuf) { return pResultBuf SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId) { int32_t slot = getGroupIndex(pResultBuf, groupId); if (slot < 0) { - return taosArrayInit(1, sizeof(int32_t)); + return pResultBuf->emptyDummyIdList; } else { return taosArrayGetP(pResultBuf->list, slot); } @@ -206,6 +207,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) { } taosArrayDestroy(pResultBuf->list); + taosArrayDestroy(pResultBuf->emptyDummyIdList); taosHashCleanup(pResultBuf->idsTable); tfree(pResultBuf->iBuf); -- GitLab