提交 b37185e5 编写于 作者: H hzcheng

fix part of mem-leak

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