提交 040e4354 编写于 作者: D dapan1121

add more free

上级 ce27353c
...@@ -97,7 +97,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { ...@@ -97,7 +97,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) { void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
if (pBuilder) { if (pBuilder) {
tfree(pBuilder->columns); TDMFREE(pBuilder->columns);
} }
} }
...@@ -187,7 +187,7 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { ...@@ -187,7 +187,7 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
* Free the SDataRow object * Free the SDataRow object
*/ */
void tdFreeDataRow(SDataRow row) { void tdFreeDataRow(SDataRow row) {
if (row) free(row); if (row) TDMFREE(row);
} }
SDataRow tdDataRowDup(SDataRow row) { SDataRow tdDataRowDup(SDataRow row) {
...@@ -339,9 +339,9 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) { ...@@ -339,9 +339,9 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
void tdFreeDataCols(SDataCols *pCols) { void tdFreeDataCols(SDataCols *pCols) {
if (pCols) { if (pCols) {
tfree(pCols->buf); TDMFREE(pCols->buf);
tfree(pCols->cols); TDMFREE(pCols->cols);
free(pCols); TDMFREE(pCols);
} }
} }
...@@ -582,7 +582,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -582,7 +582,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
} }
*orow = nrow; *orow = nrow;
free(row); TDMFREE(row);
} else { } else {
ASSERT(((SColIdx *)ptr)->colId == colId); ASSERT(((SColIdx *)ptr)->colId == colId);
if (IS_VAR_DATA_TYPE(type)) { if (IS_VAR_DATA_TYPE(type)) {
...@@ -627,7 +627,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -627,7 +627,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
} }
*orow = nrow; *orow = nrow;
free(row); TDMFREE(row);
} }
} else { } else {
memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]); memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]);
...@@ -662,15 +662,15 @@ int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) { ...@@ -662,15 +662,15 @@ int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
pBuilder->size = 0; pBuilder->size = 0;
pBuilder->buf = malloc(pBuilder->alloc); pBuilder->buf = malloc(pBuilder->alloc);
if (pBuilder->buf == NULL) { if (pBuilder->buf == NULL) {
free(pBuilder->pColIdx); TDMFREE(pBuilder->pColIdx);
return -1; return -1;
} }
return 0; return 0;
} }
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) { void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
tfree(pBuilder->pColIdx); TDMFREE(pBuilder->pColIdx);
tfree(pBuilder->buf); TDMFREE(pBuilder->buf);
} }
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) { void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
......
...@@ -125,7 +125,7 @@ void tVariantDestroy(tVariant *pVar) { ...@@ -125,7 +125,7 @@ void tVariantDestroy(tVariant *pVar) {
if (pVar == NULL) return; if (pVar == NULL) return;
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
tfree(pVar->pz); TDMFREE(pVar->pz);
pVar->nLen = 0; pVar->nLen = 0;
} }
...@@ -134,7 +134,7 @@ void tVariantDestroy(tVariant *pVar) { ...@@ -134,7 +134,7 @@ void tVariantDestroy(tVariant *pVar) {
size_t num = taosArrayGetSize(pVar->arr); size_t num = taosArrayGetSize(pVar->arr);
for(size_t i = 0; i < num; i++) { for(size_t i = 0; i < num; i++) {
void* p = taosArrayGetP(pVar->arr, i); void* p = taosArrayGetP(pVar->arr, i);
free(p); TDMFREE(p);
} }
taosArrayDestroy(pVar->arr); taosArrayDestroy(pVar->arr);
pVar->arr = NULL; pVar->arr = NULL;
...@@ -406,7 +406,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -406,7 +406,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
} }
taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf); taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf);
free(pVariant->wpz); TDMFREE(pVariant->wpz);
pBuf[newSize] = 0; pBuf[newSize] = 0;
} else { } else {
taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest); taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest);
...@@ -456,7 +456,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -456,7 +456,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
// free the binary buffer in the first place // free the binary buffer in the first place
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
free(pVariant->wpz); TDMFREE(pVariant->wpz);
} }
pVariant->wpz = pWStr; pVariant->wpz = pWStr;
...@@ -515,7 +515,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -515,7 +515,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
if (token.type == TK_NULL) { if (token.type == TK_NULL) {
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -531,7 +531,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -531,7 +531,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
if (token.type == TK_FLOAT) { if (token.type == TK_FLOAT) {
double v = strtod(pVariant->pz, &endPtr); double v = strtod(pVariant->pz, &endPtr);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -543,7 +543,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -543,7 +543,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
} else if (token.type == TK_INTEGER) { } else if (token.type == TK_INTEGER) {
int64_t val = strtoll(pVariant->pz, &endPtr, 10); int64_t val = strtoll(pVariant->pz, &endPtr, 10);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -569,7 +569,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -569,7 +569,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
if (token.type == TK_FLOAT) { if (token.type == TK_FLOAT) {
double v = wcstod(pVariant->wpz, &endPtr); double v = wcstod(pVariant->wpz, &endPtr);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -580,7 +580,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -580,7 +580,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
*result = (int64_t)v; *result = (int64_t)v;
} else if (token.type == TK_NULL) { } else if (token.type == TK_NULL) {
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
setNull((char *)result, type, tDataTypeDesc[type].nSize); setNull((char *)result, type, tDataTypeDesc[type].nSize);
...@@ -588,7 +588,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result ...@@ -588,7 +588,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
} else { } else {
int64_t val = wcstoll(pVariant->wpz, &endPtr, 10); int64_t val = wcstoll(pVariant->wpz, &endPtr, 10);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -869,21 +869,21 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { ...@@ -869,21 +869,21 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) {
errno = 0; errno = 0;
double v = strtod(pVariant->pz, NULL); double v = strtod(pVariant->pz, NULL);
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
free(pVariant->pz); TDMFREE(pVariant->pz);
return -1; return -1;
} }
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->dKey = v; pVariant->dKey = v;
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
errno = 0; errno = 0;
double v = wcstod(pVariant->wpz, NULL); double v = wcstod(pVariant->wpz, NULL);
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
free(pVariant->pz); TDMFREE(pVariant->pz);
return -1; return -1;
} }
free(pVariant->pz); TDMFREE(pVariant->pz);
pVariant->dKey = v; pVariant->dKey = v;
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
pVariant->dKey = (double)(pVariant->i64Key); pVariant->dKey = (double)(pVariant->i64Key);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define DO_FREE_HASH_NODE(_n) \ #define DO_FREE_HASH_NODE(_n) \
do { \ do { \
tfree(_n); \ TDMFREE(_n); \
} while (0) } while (0)
#define FREE_HASH_NODE(_h, _n) \ #define FREE_HASH_NODE(_h, _n) \
...@@ -514,13 +514,13 @@ void taosHashCleanup(SHashObj *pHashObj) { ...@@ -514,13 +514,13 @@ void taosHashCleanup(SHashObj *pHashObj) {
} }
taosHashEmpty(pHashObj); taosHashEmpty(pHashObj);
tfree(pHashObj->hashList); TDMFREE(pHashObj->hashList);
// destroy mem block // destroy mem block
size_t memBlock = taosArrayGetSize(pHashObj->pMemBlock); size_t memBlock = taosArrayGetSize(pHashObj->pMemBlock);
for (int32_t i = 0; i < memBlock; ++i) { for (int32_t i = 0; i < memBlock; ++i) {
void *p = taosArrayGetP(pHashObj->pMemBlock, i); void *p = taosArrayGetP(pHashObj->pMemBlock, i);
tfree(p); TDMFREE(p);
} }
taosArrayDestroy(pHashObj->pMemBlock); taosArrayDestroy(pHashObj->pMemBlock);
......
...@@ -153,7 +153,7 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const ...@@ -153,7 +153,7 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) { void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) {
char *buf = calloc(1, size); // prepare the swap buffer char *buf = calloc(1, size); // prepare the swap buffer
tqsortImpl(src, 0, (int32_t)numOfElem - 1, (int32_t)size, param, comparFn, buf); tqsortImpl(src, 0, (int32_t)numOfElem - 1, (int32_t)size, param, comparFn, buf);
tfree(buf); TDMFREE(buf);
} }
void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) { void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) {
......
...@@ -29,7 +29,7 @@ void* taosArrayInit(size_t size, size_t elemSize) { ...@@ -29,7 +29,7 @@ void* taosArrayInit(size_t size, size_t elemSize) {
pArray->pData = calloc(size, elemSize); pArray->pData = calloc(size, elemSize);
if (pArray->pData == NULL) { if (pArray->pData == NULL) {
free(pArray); TDMFREE(pArray);
return NULL; return NULL;
} }
...@@ -189,8 +189,8 @@ void taosArrayDestroy(SArray* pArray) { ...@@ -189,8 +189,8 @@ void taosArrayDestroy(SArray* pArray) {
return; return;
} }
free(pArray->pData); TDMFREE(pArray->pData);
free(pArray); TDMFREE(pArray);
} }
void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) { void taosArrayDestroyEx(SArray* pArray, void (*fp)(void*)) {
......
...@@ -104,7 +104,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo ...@@ -104,7 +104,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
pCacheObj->freeFp(pNode->data); pCacheObj->freeFp(pNode->data);
} }
free(pNode); TDMFREE(pNode);
} }
static FORCE_INLINE STrashElem* doRemoveElemInTrashcan(SCacheObj* pCacheObj, STrashElem *pElem) { static FORCE_INLINE STrashElem* doRemoveElemInTrashcan(SCacheObj* pCacheObj, STrashElem *pElem) {
...@@ -138,8 +138,8 @@ static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem ...@@ -138,8 +138,8 @@ static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem
pCacheObj->freeFp(pElem->pData->data); pCacheObj->freeFp(pElem->pData->data);
} }
free(pElem->pData); TDMFREE(pElem->pData);
free(pElem); TDMFREE(pElem);
} }
/** /**
...@@ -168,7 +168,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext ...@@ -168,7 +168,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
pCacheObj->pHashTable = taosHashInit(4096, taosGetDefaultHashFunction(keyType), false, HASH_ENTRY_LOCK); pCacheObj->pHashTable = taosHashInit(4096, taosGetDefaultHashFunction(keyType), false, HASH_ENTRY_LOCK);
pCacheObj->name = strdup(cacheName); pCacheObj->name = strdup(cacheName);
if (pCacheObj->pHashTable == NULL) { if (pCacheObj->pHashTable == NULL) {
free(pCacheObj); TDMFREE(pCacheObj);
uError("failed to allocate memory, reason:%s", strerror(errno)); uError("failed to allocate memory, reason:%s", strerror(errno));
return NULL; return NULL;
} }
...@@ -180,7 +180,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext ...@@ -180,7 +180,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
if (__cache_lock_init(pCacheObj) != 0) { if (__cache_lock_init(pCacheObj) != 0) {
taosHashCleanup(pCacheObj->pHashTable); taosHashCleanup(pCacheObj->pHashTable);
free(pCacheObj); TDMFREE(pCacheObj);
uError("failed to init lock, reason:%s", strerror(errno)); uError("failed to init lock, reason:%s", strerror(errno));
return NULL; return NULL;
...@@ -228,7 +228,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v ...@@ -228,7 +228,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
pCacheObj->freeFp(p->data); pCacheObj->freeFp(p->data);
} }
tfree(p); TDMFREE(p);
} else { } else {
taosAddToTrashcan(pCacheObj, p); taosAddToTrashcan(pCacheObj, p);
uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode1->data, p->data); uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode1->data, p->data);
...@@ -436,7 +436,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { ...@@ -436,7 +436,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
pCacheObj->freeFp(pNode->data); pCacheObj->freeFp(pNode->data);
} }
free(pNode); TDMFREE(pNode);
} }
} }
} else { } else {
...@@ -615,9 +615,9 @@ void doCleanupDataCache(SCacheObj *pCacheObj) { ...@@ -615,9 +615,9 @@ void doCleanupDataCache(SCacheObj *pCacheObj) {
__cache_lock_destroy(pCacheObj); __cache_lock_destroy(pCacheObj);
tfree(pCacheObj->name); TDMFREE(pCacheObj->name);
memset(pCacheObj, 0, sizeof(SCacheObj)); memset(pCacheObj, 0, sizeof(SCacheObj));
free(pCacheObj); TDMFREE(pCacheObj);
} }
bool travHashTableFn(void* param, void* data) { bool travHashTableFn(void* param, void* data) {
......
...@@ -226,7 +226,7 @@ static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { ...@@ -226,7 +226,7 @@ static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) {
buf[sz] = 0; buf[sz] = 0;
int32_t ret = patternMatch(pattern, buf, sz, &pInfo); int32_t ret = patternMatch(pattern, buf, sz, &pInfo);
free(buf); TDMFREE(buf);
return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; return (ret == TSDB_PATTERN_MATCH) ? 0 : 1;
} }
......
...@@ -317,7 +317,7 @@ void taosReadGlobalLogCfg() { ...@@ -317,7 +317,7 @@ void taosReadGlobalLogCfg() {
taosReadLogOption(option, value); taosReadLogOption(option, value);
} }
tfree(line); TDMFREE(line);
fclose(fp); fclose(fp);
} }
...@@ -369,7 +369,7 @@ bool taosReadGlobalCfg() { ...@@ -369,7 +369,7 @@ bool taosReadGlobalCfg() {
fclose(fp); fclose(fp);
tfree(line); TDMFREE(line);
if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) { if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) {
taosSetAllDebugFlag(); taosSetAllDebugFlag();
......
...@@ -58,7 +58,7 @@ char* taosDesDecode(int64_t key, char* src, int len) { ...@@ -58,7 +58,7 @@ char* taosDesDecode(int64_t key, char* src, int len) {
len += 8; len += 8;
char* decode = taosDesImp(keyStr, temp, len, DECRYPTION_MODE); char* decode = taosDesImp(keyStr, temp, len, DECRYPTION_MODE);
free(temp); TDMFREE(temp);
return decode; return decode;
} }
......
...@@ -31,7 +31,7 @@ void *taosInitIdPool(int maxId) { ...@@ -31,7 +31,7 @@ void *taosInitIdPool(int maxId) {
pIdPool->freeList = calloc(maxId, sizeof(bool)); pIdPool->freeList = calloc(maxId, sizeof(bool));
if (pIdPool->freeList == NULL) { if (pIdPool->freeList == NULL) {
free(pIdPool); TDMFREE(pIdPool);
return NULL; return NULL;
} }
...@@ -93,13 +93,13 @@ void taosIdPoolCleanUp(void *handle) { ...@@ -93,13 +93,13 @@ void taosIdPoolCleanUp(void *handle) {
uDebug("pool:%p is cleaned", pIdPool); uDebug("pool:%p is cleaned", pIdPool);
if (pIdPool->freeList) free(pIdPool->freeList); if (pIdPool->freeList) TDMFREE(pIdPool->freeList);
pthread_mutex_destroy(&pIdPool->mutex); pthread_mutex_destroy(&pIdPool->mutex);
memset(pIdPool, 0, sizeof(id_pool_t)); memset(pIdPool, 0, sizeof(id_pool_t));
free(pIdPool); TDMFREE(pIdPool);
} }
int taosIdPoolNumOfUsed(void *handle) { int taosIdPoolNumOfUsed(void *handle) {
...@@ -139,7 +139,7 @@ int taosUpdateIdPool(id_pool_t *handle, int maxId) { ...@@ -139,7 +139,7 @@ int taosUpdateIdPool(id_pool_t *handle, int maxId) {
bool *oldIdList = pIdPool->freeList; bool *oldIdList = pIdPool->freeList;
pIdPool->freeList = idList; pIdPool->freeList = idList;
free(oldIdList); TDMFREE(oldIdList);
pthread_mutex_unlock(&pIdPool->mutex); pthread_mutex_unlock(&pIdPool->mutex);
......
...@@ -477,11 +477,11 @@ _err: ...@@ -477,11 +477,11 @@ _err:
static void tdFreeKVStore(SKVStore *pStore) { static void tdFreeKVStore(SKVStore *pStore) {
if (pStore) { if (pStore) {
tfree(pStore->fname); TDMFREE(pStore->fname);
tfree(pStore->fsnap); TDMFREE(pStore->fsnap);
tfree(pStore->fnew); TDMFREE(pStore->fnew);
taosHashCleanup(pStore->map); taosHashCleanup(pStore->map);
free(pStore); TDMFREE(pStore);
} }
} }
...@@ -611,11 +611,11 @@ static int tdRestoreKVStore(SKVStore *pStore) { ...@@ -611,11 +611,11 @@ static int tdRestoreKVStore(SKVStore *pStore) {
if (pStore->aFunc) (*pStore->aFunc)(pStore->appH); if (pStore->aFunc) (*pStore->aFunc)(pStore->appH);
tfree(buf); TDMFREE(buf);
return 0; return 0;
_err: _err:
taosHashCancelIterate(pStore->map, pRecord); taosHashCancelIterate(pStore->map, pRecord);
tfree(buf); TDMFREE(buf);
return -1; return -1;
} }
...@@ -513,8 +513,8 @@ static SLogBuff *taosLogBuffNew(int32_t bufSize) { ...@@ -513,8 +513,8 @@ static SLogBuff *taosLogBuffNew(int32_t bufSize) {
return tLogBuff; return tLogBuff;
_err: _err:
tfree(LOG_BUF_BUFFER(tLogBuff)); TDMFREE(LOG_BUF_BUFFER(tLogBuff));
tfree(tLogBuff); TDMFREE(tLogBuff);
return NULL; return NULL;
} }
......
...@@ -52,9 +52,9 @@ mpool_h taosMemPoolInit(int numOfBlock, int blockSize) { ...@@ -52,9 +52,9 @@ mpool_h taosMemPoolInit(int numOfBlock, int blockSize) {
if (pool_p->pool == NULL || pool_p->freeList == NULL) { if (pool_p->pool == NULL || pool_p->freeList == NULL) {
uError("failed to allocate memory\n"); uError("failed to allocate memory\n");
tfree(pool_p->freeList); TDMFREE(pool_p->freeList);
tfree(pool_p->pool); TDMFREE(pool_p->pool);
tfree(pool_p); TDMFREE(pool_p);
return NULL; return NULL;
} }
...@@ -120,8 +120,8 @@ void taosMemPoolCleanUp(mpool_h handle) { ...@@ -120,8 +120,8 @@ void taosMemPoolCleanUp(mpool_h handle) {
pool_t *pool_p = (pool_t *)handle; pool_t *pool_p = (pool_t *)handle;
pthread_mutex_destroy(&pool_p->mutex); pthread_mutex_destroy(&pool_p->mutex);
if (pool_p->pool) free(pool_p->pool); if (pool_p->pool) TDMFREE(pool_p->pool);
if (pool_p->freeList) free(pool_p->freeList); if (pool_p->freeList) TDMFREE(pool_p->freeList);
memset(pool_p, 0, sizeof(*pool_p)); memset(pool_p, 0, sizeof(*pool_p));
free(pool_p); TDMFREE(pool_p);
} }
...@@ -406,7 +406,7 @@ static void taosNetTestStartup(char *host, int32_t port) { ...@@ -406,7 +406,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
} }
} }
free(pStep); TDMFREE(pStep);
} }
static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) { static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
......
...@@ -82,11 +82,11 @@ void taosCloseQueue(taos_queue param) { ...@@ -82,11 +82,11 @@ void taosCloseQueue(taos_queue param) {
while (pNode) { while (pNode) {
pTemp = pNode; pTemp = pNode;
pNode = pNode->next; pNode = pNode->next;
free (pTemp); TDMFREE (pTemp);
} }
pthread_mutex_destroy(&queue->mutex); pthread_mutex_destroy(&queue->mutex);
free(queue); TDMFREE(queue);
uTrace("queue:%p is closed", queue); uTrace("queue:%p is closed", queue);
} }
...@@ -105,7 +105,7 @@ void taosFreeQitem(void *param) { ...@@ -105,7 +105,7 @@ void taosFreeQitem(void *param) {
char *temp = (char *)param; char *temp = (char *)param;
temp -= sizeof(STaosQnode); temp -= sizeof(STaosQnode);
uTrace("item:%p, node:%p is freed", param, temp); uTrace("item:%p, node:%p is freed", param, temp);
free(temp); TDMFREE(temp);
} }
int taosWriteQitem(taos_queue param, int type, void *item) { int taosWriteQitem(taos_queue param, int type, void *item) {
...@@ -166,7 +166,7 @@ void *taosAllocateQall() { ...@@ -166,7 +166,7 @@ void *taosAllocateQall() {
} }
void taosFreeQall(void *param) { void taosFreeQall(void *param) {
free(param); TDMFREE(param);
} }
int taosReadAllQitems(taos_queue param, taos_qall p2) { int taosReadAllQitems(taos_queue param, taos_qall p2) {
...@@ -251,7 +251,7 @@ void taosCloseQset(taos_qset param) { ...@@ -251,7 +251,7 @@ void taosCloseQset(taos_qset param) {
pthread_mutex_destroy(&qset->mutex); pthread_mutex_destroy(&qset->mutex);
tsem_destroy(&qset->sem); tsem_destroy(&qset->sem);
free(qset); TDMFREE(qset);
uTrace("qset:%p is closed", qset); uTrace("qset:%p is closed", qset);
} }
......
...@@ -73,7 +73,7 @@ int taosOpenRef(int max, void (*fp)(void *)) ...@@ -73,7 +73,7 @@ int taosOpenRef(int max, void (*fp)(void *))
lockedBy = calloc(sizeof(int64_t), (size_t)max); lockedBy = calloc(sizeof(int64_t), (size_t)max);
if (lockedBy == NULL) { if (lockedBy == NULL) {
free(nodeList); TDMFREE(nodeList);
terrno = TSDB_CODE_REF_NO_MEMORY; terrno = TSDB_CODE_REF_NO_MEMORY;
return -1; return -1;
} }
...@@ -102,8 +102,8 @@ int taosOpenRef(int max, void (*fp)(void *)) ...@@ -102,8 +102,8 @@ int taosOpenRef(int max, void (*fp)(void *))
uTrace("rsetId:%d is opened, max:%d, fp:%p refSetNum:%d", rsetId, max, fp, tsRefSetNum); uTrace("rsetId:%d is opened, max:%d, fp:%p refSetNum:%d", rsetId, max, fp, tsRefSetNum);
} else { } else {
rsetId = TSDB_CODE_REF_FULL; rsetId = TSDB_CODE_REF_FULL;
free (nodeList); TDMFREE (nodeList);
free (lockedBy); TDMFREE (lockedBy);
uTrace("run out of Ref ID, maximum:%d refSetNum:%d", TSDB_REF_OBJECTS, tsRefSetNum); uTrace("run out of Ref ID, maximum:%d refSetNum:%d", TSDB_REF_OBJECTS, tsRefSetNum);
} }
...@@ -438,7 +438,7 @@ static int taosDecRefCount(int rsetId, int64_t rid, int remove) { ...@@ -438,7 +438,7 @@ static int taosDecRefCount(int rsetId, int64_t rid, int remove) {
if (released) { if (released) {
uTrace("rsetId:%d p:%p rid:%" PRId64 " is removed, count:%d, free mem: %p", rsetId, pNode->p, rid, pSet->count, pNode); uTrace("rsetId:%d p:%p rid:%" PRId64 " is removed, count:%d, free mem: %p", rsetId, pNode->p, rid, pSet->count, pNode);
(*pSet->fp)(pNode->p); (*pSet->fp)(pNode->p);
free(pNode); TDMFREE(pNode);
taosDecRsetCount(pSet); taosDecRsetCount(pSet);
} }
...@@ -485,8 +485,8 @@ static void taosDecRsetCount(SRefSet *pSet) { ...@@ -485,8 +485,8 @@ static void taosDecRsetCount(SRefSet *pSet) {
pSet->max = 0; pSet->max = 0;
pSet->fp = NULL; pSet->fp = NULL;
tfree(pSet->nodeList); TDMFREE(pSet->nodeList);
tfree(pSet->lockedBy); TDMFREE(pSet->lockedBy);
tsRefSetNum--; tsRefSetNum--;
uTrace("rsetId:%d is cleaned, refSetNum:%d count:%d", pSet->rsetId, tsRefSetNum, pSet->count); uTrace("rsetId:%d is cleaned, refSetNum:%d count:%d", pSet->rsetId, tsRefSetNum, pSet->count);
......
...@@ -201,9 +201,9 @@ void taosCleanUpScheduler(void *param) { ...@@ -201,9 +201,9 @@ void taosCleanUpScheduler(void *param) {
taosTmrStopA(&pSched->pTimer); taosTmrStopA(&pSched->pTimer);
} }
if (pSched->queue) free(pSched->queue); if (pSched->queue) TDMFREE(pSched->queue);
if (pSched->qthread) free(pSched->qthread); if (pSched->qthread) TDMFREE(pSched->qthread);
free(pSched); // fix memory leak TDMFREE(pSched); // fix memory leak
} }
// for debug purpose, dump the scheduler status every 1min. // for debug purpose, dump the scheduler status every 1min.
......
...@@ -27,7 +27,7 @@ static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t ...@@ -27,7 +27,7 @@ static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t
static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **direction, SSkipListNode *pNode, bool isForward); static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **direction, SSkipListNode *pNode, bool isForward);
static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **backward, void *pData); static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **backward, void *pData);
static SSkipListNode *tSkipListNewNode(uint8_t level); static SSkipListNode *tSkipListNewNode(uint8_t level);
#define tSkipListFreeNode(n) tfree((n)) #define tSkipListFreeNode(n) TDMFREE((n))
static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipListNode **direction, bool isForward, static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipListNode **direction, bool isForward,
bool hasDup); bool hasDup);
...@@ -99,12 +99,12 @@ void tSkipListDestroy(SSkipList *pSkipList) { ...@@ -99,12 +99,12 @@ void tSkipListDestroy(SSkipList *pSkipList) {
tSkipListUnlock(pSkipList); tSkipListUnlock(pSkipList);
if (pSkipList->lock != NULL) { if (pSkipList->lock != NULL) {
pthread_rwlock_destroy(pSkipList->lock); pthread_rwlock_destroy(pSkipList->lock);
tfree(pSkipList->lock); TDMFREE(pSkipList->lock);
} }
tSkipListFreeNode(pSkipList->pHead); tSkipListFreeNode(pSkipList->pHead);
tSkipListFreeNode(pSkipList->pTail); tSkipListFreeNode(pSkipList->pTail);
tfree(pSkipList); TDMFREE(pSkipList);
} }
SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) { SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) {
...@@ -332,7 +332,7 @@ void *tSkipListDestroyIter(SSkipListIterator *iter) { ...@@ -332,7 +332,7 @@ void *tSkipListDestroyIter(SSkipListIterator *iter) {
return NULL; return NULL;
} }
tfree(iter); TDMFREE(iter);
return NULL; return NULL;
} }
......
...@@ -38,7 +38,7 @@ char* taosStringBuilderGetResult(SStringBuilder* sb, size_t* len) { ...@@ -38,7 +38,7 @@ char* taosStringBuilderGetResult(SStringBuilder* sb, size_t* len) {
} }
void taosStringBuilderDestroy(SStringBuilder* sb) { void taosStringBuilderDestroy(SStringBuilder* sb) {
free(sb->buf); TDMFREE(sb->buf);
sb->buf = NULL; sb->buf = NULL;
sb->pos = 0; sb->pos = 0;
sb->size = 0; sb->size = 0;
......
...@@ -114,7 +114,7 @@ static void timerAddRef(tmr_obj_t* timer) { atomic_add_fetch_8(&timer->refCount, ...@@ -114,7 +114,7 @@ static void timerAddRef(tmr_obj_t* timer) { atomic_add_fetch_8(&timer->refCount,
static void timerDecRef(tmr_obj_t* timer) { static void timerDecRef(tmr_obj_t* timer) {
if (atomic_sub_fetch_8(&timer->refCount, 1) == 0) { if (atomic_sub_fetch_8(&timer->refCount, 1) == 0) {
free(timer); TDMFREE(timer);
} }
} }
...@@ -575,7 +575,7 @@ void taosTmrCleanUp(void* handle) { ...@@ -575,7 +575,7 @@ void taosTmrCleanUp(void* handle) {
for (int i = 0; i < tListLen(wheels); i++) { for (int i = 0; i < tListLen(wheels); i++) {
time_wheel_t* wheel = wheels + i; time_wheel_t* wheel = wheels + i;
pthread_mutex_destroy(&wheel->mutex); pthread_mutex_destroy(&wheel->mutex);
free(wheel->slots); TDMFREE(wheel->slots);
} }
pthread_mutex_destroy(&tmrCtrlMutex); pthread_mutex_destroy(&tmrCtrlMutex);
...@@ -585,12 +585,12 @@ void taosTmrCleanUp(void* handle) { ...@@ -585,12 +585,12 @@ void taosTmrCleanUp(void* handle) {
tmr_obj_t* t = list->timers; tmr_obj_t* t = list->timers;
while (t != NULL) { while (t != NULL) {
tmr_obj_t* next = t->mnext; tmr_obj_t* next = t->mnext;
free(t); TDMFREE(t);
t = next; t = next;
} }
} }
free(timerMap.slots); TDMFREE(timerMap.slots);
free(tmrCtrls); TDMFREE(tmrCtrls);
tmrDebug("timer module is cleaned up"); tmrDebug("timer module is cleaned up");
} }
......
...@@ -48,7 +48,7 @@ void tWorkerCleanup(SWorkerPool *pPool) { ...@@ -48,7 +48,7 @@ void tWorkerCleanup(SWorkerPool *pPool) {
} }
} }
free(pPool->worker); TDMFREE(pPool->worker);
taosCloseQset(pPool->qset); taosCloseQset(pPool->qset);
pthread_mutex_destroy(&pPool->mutex); pthread_mutex_destroy(&pPool->mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册