未验证 提交 775c8938 编写于 作者: S slguan 提交者: GitHub

Merge pull request #1564 from taosdata/hotfix/mem_leak

fix part of mem-leak
......@@ -141,7 +141,7 @@ STSchema *tdDupSchema(STSchema *pSchema) {
* Free the SSchema object created by tdNewSchema or tdDupSchema
*/
void tdFreeSchema(STSchema *pSchema) {
if (pSchema == NULL) free(pSchema);
if (pSchema != NULL) free(pSchema);
}
/**
......
......@@ -25,6 +25,7 @@
#include "dataformat.h"
#include "vnode.h"
#include "vnodeInt.h"
#include "tutil.h"
static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, SRspRet *);
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
......@@ -157,6 +158,8 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
void *pTsdb = vnodeGetTsdb(pVnode);
code = tsdbCreateTable(pTsdb, &tCfg);
tfree(pDestSchema);
dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code);
return code;
}
......
......@@ -62,6 +62,7 @@ STsdbFileH *tsdbInitFileH(char *dataDir, int maxFiles) {
// TODO
}
}
closedir(dir);
return pFileH;
}
......
......@@ -268,6 +268,9 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
tsdbFreeCache(pRepo->tsdbCache);
tfree(pRepo->rootDir);
tfree(pRepo);
return 0;
}
......@@ -847,6 +850,7 @@ static void *tsdbCommitData(void *arg) {
tsdbLockRepo(arg);
tdListMove(pCache->imem->list, pCache->pool.memPool);
tdListFree(pCache->imem->list);
free(pCache->imem);
pCache->imem = NULL;
pRepo->commit = 0;
......@@ -1125,11 +1129,11 @@ static int tsdbWriteBlockToFileImpl(SFile *pFile, SDataCols *pCols, int pointsTo
*len += pCompCol->len;
}
if (pCompData == NULL) free((void *)pCompData);
tfree(pCompData);
return 0;
_err:
if (pCompData == NULL) free((void *)pCompData);
tfree(pCompData);
return -1;
}
......
......@@ -312,6 +312,14 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
// return 0;
// }
static void tsdbFreeMemTable(SMemTable *pMemTable) {
if (pMemTable) {
tSkipListDestroy(pMemTable->pData);
}
free(pMemTable);
}
static int tsdbFreeTable(STable *pTable) {
// TODO: finish this function
if (pTable->type == TSDB_CHILD_TABLE) {
......@@ -323,7 +331,10 @@ static int tsdbFreeTable(STable *pTable) {
// Free content
if (TSDB_TABLE_IS_SUPER_TABLE(pTable)) {
tSkipListDestroy(pTable->pIndex);
}
}
tsdbFreeMemTable(pTable->mem);
tsdbFreeMemTable(pTable->imem);
free(pTable);
return 0;
......
......@@ -177,6 +177,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh) {
close(mfh->fd);
taosHashCleanup(mfh->map);
tfree(mfh);
}
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册