Merge pull request #1596 from taosdata/hotfix/fix_valgrind_warning
fix valgrind warning
This commit is contained in:
commit
2900f2bddd
|
@ -813,6 +813,13 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables)
|
||||||
return iters;
|
return iters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tsdbFreeMemTable(SMemTable *pMemTable) {
|
||||||
|
if (pMemTable) {
|
||||||
|
tSkipListDestroy(pMemTable->pData);
|
||||||
|
free(pMemTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Commit to file
|
// Commit to file
|
||||||
static void *tsdbCommitData(void *arg) {
|
static void *tsdbCommitData(void *arg) {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -859,7 +866,8 @@ static void *tsdbCommitData(void *arg) {
|
||||||
// TODO: free the skiplist
|
// TODO: free the skiplist
|
||||||
for (int i = 0; i < pCfg->maxTables; i++) {
|
for (int i = 0; i < pCfg->maxTables; i++) {
|
||||||
STable *pTable = pMeta->tables[i];
|
STable *pTable = pMeta->tables[i];
|
||||||
if (pTable && pTable->imem) { // Here has memory leak
|
if (pTable && pTable->imem) {
|
||||||
|
tsdbFreeMemTable(pTable->imem);
|
||||||
pTable->imem = NULL;
|
pTable->imem = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ void *tsdbEncodeTable(STable *pTable, int *contLen) {
|
||||||
*contLen = tsdbEstimateTableEncodeSize(pTable);
|
*contLen = tsdbEstimateTableEncodeSize(pTable);
|
||||||
if (*contLen < 0) return NULL;
|
if (*contLen < 0) return NULL;
|
||||||
|
|
||||||
void *ret = malloc(*contLen);
|
void *ret = calloc(1, *contLen);
|
||||||
if (ret == NULL) return NULL;
|
if (ret == NULL) return NULL;
|
||||||
|
|
||||||
void *ptr = ret;
|
void *ptr = ret;
|
||||||
|
|
Loading…
Reference in New Issue