提交 25344869 编写于 作者: L Liu Jicong

merge from 3.0

...@@ -104,16 +104,16 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) { ...@@ -104,16 +104,16 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
for (int32_t i = 0; i < numOfOutput; ++i) { for (int32_t i = 0; i < numOfOutput; ++i) {
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
tfree(pColInfoData->varmeta.offset); taosMemoryFreeClear(pColInfoData->varmeta.offset);
} else { } else {
tfree(pColInfoData->nullbitmap); taosMemoryFreeClear(pColInfoData->nullbitmap);
} }
tfree(pColInfoData->pData); taosMemoryFreeClear(pColInfoData->pData);
} }
taosArrayDestroy(pBlock->pDataBlock); taosArrayDestroy(pBlock->pDataBlock);
tfree(pBlock->pBlockAgg); taosMemoryFreeClear(pBlock->pBlockAgg);
} }
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); } static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); }
...@@ -147,7 +147,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) { ...@@ -147,7 +147,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum); buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
buf = taosDecodeFixedI32(buf, &pRsp->numOfTopics); buf = taosDecodeFixedI32(buf, &pRsp->numOfTopics);
if (pRsp->numOfTopics == 0) return buf; if (pRsp->numOfTopics == 0) return buf;
pRsp->schema = (SSchemaWrapper*)calloc(1, sizeof(SSchemaWrapper)); pRsp->schema = (SSchemaWrapper*)taosMemoryCalloc(1, sizeof(SSchemaWrapper));
if (pRsp->schema == NULL) return NULL; if (pRsp->schema == NULL) return NULL;
buf = tDecodeSSchemaWrapper(buf, pRsp->schema); buf = tDecodeSSchemaWrapper(buf, pRsp->schema);
buf = taosDecodeFixedI32(buf, &sz); buf = taosDecodeFixedI32(buf, &sz);
...@@ -163,9 +163,9 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) { ...@@ -163,9 +163,9 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) { static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
if (pRsp->schema) { if (pRsp->schema) {
if (pRsp->schema->nCols) { if (pRsp->schema->nCols) {
tfree(pRsp->schema->pSchema); taosMemoryFreeClear(pRsp->schema->pSchema);
} }
free(pRsp->schema); taosMemoryFree(pRsp->schema);
} }
taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))blockDestroyInner); taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))blockDestroyInner);
pRsp->pBlockData = NULL; pRsp->pBlockData = NULL;
......
...@@ -93,7 +93,7 @@ typedef struct { ...@@ -93,7 +93,7 @@ typedef struct {
#define schemaFLen(s) ((s)->flen) #define schemaFLen(s) ((s)->flen)
#define schemaVLen(s) ((s)->vlen) #define schemaVLen(s) ((s)->vlen)
#define schemaColAt(s, i) ((s)->columns + i) #define schemaColAt(s, i) ((s)->columns + i)
#define tdFreeSchema(s) tfree((s)) #define tdFreeSchema(s) taosMemoryFreeClear((s))
STSchema *tdDupSchema(const STSchema *pSchema); STSchema *tdDupSchema(const STSchema *pSchema);
int32_t tdEncodeSchema(void **buf, STSchema *pSchema); int32_t tdEncodeSchema(void **buf, STSchema *pSchema);
...@@ -493,7 +493,7 @@ typedef struct { ...@@ -493,7 +493,7 @@ typedef struct {
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r)) #define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset) #define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i)) #define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
#define kvRowFree(r) tfree(r) #define kvRowFree(r) taosMemoryFreeClear(r)
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r)) #define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
#define kvRowValLen(r) (kvRowLen(r) - TD_KV_ROW_HEAD_SIZE - sizeof(SColIdx) * kvRowNCols(r)) #define kvRowValLen(r) (kvRowLen(r) - TD_KV_ROW_HEAD_SIZE - sizeof(SColIdx) * kvRowNCols(r))
#define kvRowTKey(r) (*(TKEY *)(kvRowValues(r))) #define kvRowTKey(r) (*(TKEY *)(kvRowValues(r)))
...@@ -593,7 +593,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder); ...@@ -593,7 +593,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder);
static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, const void *value) { static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, const void *value) {
if (pBuilder->nCols >= pBuilder->tCols) { if (pBuilder->nCols >= pBuilder->tCols) {
pBuilder->tCols *= 2; pBuilder->tCols *= 2;
SColIdx *pColIdx = (SColIdx *)realloc((void *)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols); SColIdx *pColIdx = (SColIdx *)taosMemoryRealloc((void *)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols);
if (pColIdx == NULL) return -1; if (pColIdx == NULL) return -1;
pBuilder->pColIdx = pColIdx; pBuilder->pColIdx = pColIdx;
} }
...@@ -608,7 +608,7 @@ static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t col ...@@ -608,7 +608,7 @@ static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t col
while (tlen > pBuilder->alloc - pBuilder->size) { while (tlen > pBuilder->alloc - pBuilder->size) {
pBuilder->alloc *= 2; pBuilder->alloc *= 2;
} }
void *buf = realloc(pBuilder->buf, pBuilder->alloc); void *buf = taosMemoryRealloc(pBuilder->buf, pBuilder->alloc);
if (buf == NULL) return -1; if (buf == NULL) return -1;
pBuilder->buf = buf; pBuilder->buf = buf;
} }
......
...@@ -1309,7 +1309,7 @@ typedef struct { ...@@ -1309,7 +1309,7 @@ typedef struct {
} SMqRebSubscribe; } SMqRebSubscribe;
static FORCE_INLINE SMqRebSubscribe* tNewSMqRebSubscribe(const char* key) { static FORCE_INLINE SMqRebSubscribe* tNewSMqRebSubscribe(const char* key) {
SMqRebSubscribe* pRebSub = (SMqRebSubscribe*)calloc(1, sizeof(SMqRebSubscribe)); SMqRebSubscribe* pRebSub = (SMqRebSubscribe*)taosMemoryCalloc(1, sizeof(SMqRebSubscribe));
if (pRebSub == NULL) { if (pRebSub == NULL) {
goto _err; goto _err;
} }
...@@ -1331,7 +1331,7 @@ _err: ...@@ -1331,7 +1331,7 @@ _err:
taosArrayDestroy(pRebSub->lostConsumers); taosArrayDestroy(pRebSub->lostConsumers);
taosArrayDestroy(pRebSub->removedConsumers); taosArrayDestroy(pRebSub->removedConsumers);
taosArrayDestroy(pRebSub->newConsumers); taosArrayDestroy(pRebSub->newConsumers);
tfree(pRebSub); taosMemoryFreeClear(pRebSub);
return NULL; return NULL;
} }
...@@ -1632,7 +1632,7 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) { ...@@ -1632,7 +1632,7 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
void* pIter = taosHashIterate(info, NULL); void* pIter = taosHashIterate(info, NULL);
while (pIter != NULL) { while (pIter != NULL) {
SKv* kv = (SKv*)pIter; SKv* kv = (SKv*)pIter;
tfree(kv->value); taosMemoryFreeClear(kv->value);
pIter = taosHashIterate(info, pIter); pIter = taosHashIterate(info, pIter);
} }
} }
...@@ -1655,13 +1655,13 @@ static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq, bool deep) { ...@@ -1655,13 +1655,13 @@ static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq, bool deep) {
} else { } else {
taosArrayDestroy(req->reqs); taosArrayDestroy(req->reqs);
} }
free(pReq); taosMemoryFree(pReq);
} }
static FORCE_INLINE void tFreeClientKv(void* pKv) { static FORCE_INLINE void tFreeClientKv(void* pKv) {
SKv* kv = (SKv*)pKv; SKv* kv = (SKv*)pKv;
if (kv) { if (kv) {
tfree(kv->value); taosMemoryFreeClear(kv->value);
} }
} }
...@@ -1688,7 +1688,7 @@ static FORCE_INLINE int32_t tEncodeSKv(SCoder* pEncoder, const SKv* pKv) { ...@@ -1688,7 +1688,7 @@ static FORCE_INLINE int32_t tEncodeSKv(SCoder* pEncoder, const SKv* pKv) {
static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) { static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1; if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1; if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
pKv->value = malloc(pKv->valueLen + 1); pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
if (pKv->value == NULL) return -1; if (pKv->value == NULL) return -1;
if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1; if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1;
return 0; return 0;
...@@ -1942,7 +1942,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp ...@@ -1942,7 +1942,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) { static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) {
buf = taosDecodeFixedU32(buf, &pSW->nCols); buf = taosDecodeFixedU32(buf, &pSW->nCols);
pSW->pSchema = (SSchema*)calloc(pSW->nCols, sizeof(SSchema)); pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
if (pSW->pSchema == NULL) { if (pSW->pSchema == NULL) {
return NULL; return NULL;
} }
...@@ -2077,8 +2077,8 @@ typedef struct { ...@@ -2077,8 +2077,8 @@ typedef struct {
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) { static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
if (pSma) { if (pSma) {
tfree(pSma->expr); taosMemoryFreeClear(pSma->expr);
tfree(pSma->tagsFilter); taosMemoryFreeClear(pSma->tagsFilter);
} }
} }
...@@ -2088,14 +2088,14 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) { ...@@ -2088,14 +2088,14 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
for (uint32_t i = 0; i < pSW->number; ++i) { for (uint32_t i = 0; i < pSW->number; ++i) {
tdDestroyTSma(pSW->tSma + i); tdDestroyTSma(pSW->tSma + i);
} }
tfree(pSW->tSma); taosMemoryFreeClear(pSW->tSma);
} }
} }
} }
static FORCE_INLINE void tdFreeTSmaWrapper(STSmaWrapper* pSW) { static FORCE_INLINE void tdFreeTSmaWrapper(STSmaWrapper* pSW) {
tdDestroyTSmaWrapper(pSW); tdDestroyTSmaWrapper(pSW);
tfree(pSW); taosMemoryFreeClear(pSW);
} }
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
...@@ -2173,7 +2173,7 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { ...@@ -2173,7 +2173,7 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) { static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
buf = taosDecodeFixedU32(buf, &pSW->number); buf = taosDecodeFixedU32(buf, &pSW->number);
pSW->tSma = (STSma*)calloc(pSW->number, sizeof(STSma)); pSW->tSma = (STSma*)taosMemoryCalloc(pSW->number, sizeof(STSma));
if (pSW->tSma == NULL) { if (pSW->tSma == NULL) {
return NULL; return NULL;
} }
...@@ -2183,7 +2183,7 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) { ...@@ -2183,7 +2183,7 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
for (uint32_t j = i; j >= 0; --i) { for (uint32_t j = i; j >= 0; --i) {
tdDestroyTSma(pSW->tSma + j); tdDestroyTSma(pSW->tSma + j);
} }
free(pSW->tSma); taosMemoryFree(pSW->tSma);
return NULL; return NULL;
} }
} }
......
...@@ -57,18 +57,19 @@ typedef enum EFunctionType { ...@@ -57,18 +57,19 @@ typedef enum EFunctionType {
// math function // math function
FUNCTION_TYPE_ABS = 1000, FUNCTION_TYPE_ABS = 1000,
FUNCTION_TYPE_ACOS,
FUNCTION_TYPE_ASION,
FUNCTION_TYPE_ATAN,
FUNCTION_TYPE_CEIL,
FUNCTION_TYPE_COS,
FUNCTION_TYPE_FLOOR,
FUNCTION_TYPE_LOG, FUNCTION_TYPE_LOG,
FUNCTION_TYPE_POW, FUNCTION_TYPE_POW,
FUNCTION_TYPE_SQRT,
FUNCTION_TYPE_CEIL,
FUNCTION_TYPE_FLOOR,
FUNCTION_TYPE_ROUND, FUNCTION_TYPE_ROUND,
FUNCTION_TYPE_SIN, FUNCTION_TYPE_SIN,
FUNCTION_TYPE_SQRT, FUNCTION_TYPE_COS,
FUNCTION_TYPE_TAN, FUNCTION_TYPE_TAN,
FUNCTION_TYPE_ASIN,
FUNCTION_TYPE_ACOS,
FUNCTION_TYPE_ATAN,
// string function // string function
FUNCTION_TYPE_CHAR_LENGTH = 1500, FUNCTION_TYPE_CHAR_LENGTH = 1500,
......
...@@ -42,6 +42,21 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type); ...@@ -42,6 +42,21 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
int32_t vectorGetConvertType(int32_t type1, int32_t type2); int32_t vectorGetConvertType(int32_t type1, int32_t type2);
int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut); int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut);
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t logFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t powFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t sqrtFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t sinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t cosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t tanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t asinFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t acosFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t ceilFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t floorFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t roundFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -83,7 +83,7 @@ typedef struct SRpcInit { ...@@ -83,7 +83,7 @@ typedef struct SRpcInit {
typedef struct { typedef struct {
void * val; void * val;
int32_t len; int32_t len;
void (*free)(void *arg); void (*freeFunc)(const void *arg);
} SRpcCtxVal; } SRpcCtxVal;
typedef struct { typedef struct {
......
...@@ -20,12 +20,25 @@ ...@@ -20,12 +20,25 @@
extern "C" { extern "C" {
#endif #endif
#define tfree(x) \ // If the error is in a third-party library, place this header file under the third-party library header file.
do { \ // When you want to use this feature, you should find or add the same function in the following sectio
if (x) { \ #ifndef ALLOW_FORBID_FUNC
free((void *)(x)); \ #define malloc MALLOC_FUNC_TAOS_FORBID
(x) = 0; \ #define calloc CALLOC_FUNC_TAOS_FORBID
} \ #define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID
#endif
void *taosMemoryMalloc(int32_t size);
void *taosMemoryCalloc(int32_t num, int32_t size);
void *taosMemoryRealloc(void *ptr, int32_t size);
void taosMemoryFree(const void *ptr);
int32_t taosMemorySize(void *ptr);
#define taosMemoryFreeClear(ptr) \
do { \
taosMemoryFree(ptr); \
(ptr)=NULL; \
} while (0) } while (0)
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -351,7 +351,7 @@ static FORCE_INLINE void *taosDecodeString(const void *buf, char **value) { ...@@ -351,7 +351,7 @@ static FORCE_INLINE void *taosDecodeString(const void *buf, char **value) {
uint64_t size = 0; uint64_t size = 0;
buf = taosDecodeVariantU64(buf, &size); buf = taosDecodeVariantU64(buf, &size);
*value = (char *)malloc((size_t)size + 1); *value = (char *)taosMemoryMalloc((size_t)size + 1);
if (*value == NULL) return NULL; if (*value == NULL) return NULL;
memcpy(*value, buf, (size_t)size); memcpy(*value, buf, (size_t)size);
...@@ -386,7 +386,7 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3 ...@@ -386,7 +386,7 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
} }
static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) { static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) {
*value = malloc((size_t)valueLen); *value = taosMemoryMalloc((size_t)valueLen);
if (*value == NULL) return NULL; if (*value == NULL) return NULL;
memcpy(*value, buf, (size_t)valueLen); memcpy(*value, buf, (size_t)valueLen);
......
...@@ -406,7 +406,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uin ...@@ -406,7 +406,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uin
if (tDecodeU64v(pDecoder, len) < 0) return -1; if (tDecodeU64v(pDecoder, len) < 0) return -1;
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1; if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1;
*val = malloc(*len); *val = taosMemoryMalloc(*len);
if (*val == NULL) return -1; if (*val == NULL) return -1;
memcpy(*val, TD_CODER_CURRENT(pDecoder), *len); memcpy(*val, TD_CODER_CURRENT(pDecoder), *len);
......
...@@ -31,7 +31,7 @@ typedef TD_SLIST(SFreeListNode) SFreeList; ...@@ -31,7 +31,7 @@ typedef TD_SLIST(SFreeListNode) SFreeList;
#define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \ #define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \
do { \ do { \
void *ptr = malloc((SIZE) + sizeof(struct SFreeListNode)); \ void *ptr = taosMemoryMalloc((SIZE) + sizeof(struct SFreeListNode)); \
if (ptr) { \ if (ptr) { \
TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \ TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \
ptr = ((struct SFreeListNode *)ptr)->payload; \ ptr = ((struct SFreeListNode *)ptr)->payload; \
...@@ -49,7 +49,7 @@ static FORCE_INLINE void tFreeListClear(SFreeList *pFL) { ...@@ -49,7 +49,7 @@ static FORCE_INLINE void tFreeListClear(SFreeList *pFL) {
pNode = TD_SLIST_HEAD(pFL); pNode = TD_SLIST_HEAD(pFL);
if (pNode == NULL) break; if (pNode == NULL) break;
TD_SLIST_POP(pFL); TD_SLIST_POP(pFL);
free(pNode); taosMemoryFree(pNode);
} }
} }
......
...@@ -216,7 +216,7 @@ typedef struct { ...@@ -216,7 +216,7 @@ typedef struct {
#define listNEles(l) TD_DLIST_NELES(l) #define listNEles(l) TD_DLIST_NELES(l)
#define listEleSize(l) ((l)->eleSize) #define listEleSize(l) ((l)->eleSize)
#define isListEmpty(l) (TD_DLIST_NELES(l) == 0) #define isListEmpty(l) (TD_DLIST_NELES(l) == 0)
#define listNodeFree(n) free(n) #define listNodeFree(n) taosMemoryFree(n)
void tdListInit(SList *list, int32_t eleSize); void tdListInit(SList *list, int32_t eleSize);
void tdListEmpty(SList *list); void tdListEmpty(SList *list);
......
...@@ -115,11 +115,11 @@ void destroyTscObj(void *pObj) { ...@@ -115,11 +115,11 @@ void destroyTscObj(void *pObj) {
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1); atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns); tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
taosThreadMutexDestroy(&pTscObj->mutex); taosThreadMutexDestroy(&pTscObj->mutex);
tfree(pTscObj); taosMemoryFreeClear(pTscObj);
} }
void *createTscObj(const char *user, const char *auth, const char *db, SAppInstInfo *pAppInfo) { void *createTscObj(const char *user, const char *auth, const char *db, SAppInstInfo *pAppInfo) {
STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj)); STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
if (NULL == pObj) { if (NULL == pObj) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -143,7 +143,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI ...@@ -143,7 +143,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) { void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
assert(pObj != NULL); assert(pObj != NULL);
SRequestObj *pRequest = (SRequestObj *)calloc(1, sizeof(SRequestObj)); SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
if (NULL == pRequest) { if (NULL == pRequest) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -156,7 +156,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty ...@@ -156,7 +156,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
pRequest->type = type; pRequest->type = type;
pRequest->pTscObj = pObj; pRequest->pTscObj = pObj;
pRequest->body.fp = fp; // not used it yet pRequest->body.fp = fp; // not used it yet
pRequest->msgBuf = calloc(1, ERROR_MSG_BUF_DEFAULT_SIZE); pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
tsem_init(&pRequest->body.rspSem, 0, 0); tsem_init(&pRequest->body.rspSem, 0, 0);
registerRequest(pRequest); registerRequest(pRequest);
...@@ -164,17 +164,17 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty ...@@ -164,17 +164,17 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
} }
static void doFreeReqResultInfo(SReqResultInfo *pResInfo) { static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
tfree(pResInfo->pRspMsg); taosMemoryFreeClear(pResInfo->pRspMsg);
tfree(pResInfo->length); taosMemoryFreeClear(pResInfo->length);
tfree(pResInfo->row); taosMemoryFreeClear(pResInfo->row);
tfree(pResInfo->pCol); taosMemoryFreeClear(pResInfo->pCol);
tfree(pResInfo->fields); taosMemoryFreeClear(pResInfo->fields);
if (pResInfo->convertBuf != NULL) { if (pResInfo->convertBuf != NULL) {
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) { for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
tfree(pResInfo->convertBuf[i]); taosMemoryFreeClear(pResInfo->convertBuf[i]);
} }
tfree(pResInfo->convertBuf); taosMemoryFreeClear(pResInfo->convertBuf);
} }
} }
...@@ -184,10 +184,10 @@ static void doDestroyRequest(void *p) { ...@@ -184,10 +184,10 @@ static void doDestroyRequest(void *p) {
assert(RID_VALID(pRequest->self)); assert(RID_VALID(pRequest->self));
tfree(pRequest->msgBuf); taosMemoryFreeClear(pRequest->msgBuf);
tfree(pRequest->sqlstr); taosMemoryFreeClear(pRequest->sqlstr);
tfree(pRequest->pInfo); taosMemoryFreeClear(pRequest->pInfo);
tfree(pRequest->pDb); taosMemoryFreeClear(pRequest->pDb);
doFreeReqResultInfo(&pRequest->body.resInfo); doFreeReqResultInfo(&pRequest->body.resInfo);
qDestroyQueryPlan(pRequest->body.pDag); qDestroyQueryPlan(pRequest->body.pDag);
...@@ -197,7 +197,7 @@ static void doDestroyRequest(void *p) { ...@@ -197,7 +197,7 @@ static void doDestroyRequest(void *p) {
} }
deregisterRequest(pRequest); deregisterRequest(pRequest);
tfree(pRequest); taosMemoryFreeClear(pRequest);
} }
void destroyRequest(SRequestObj *pRequest) { void destroyRequest(SRequestObj *pRequest) {
...@@ -356,7 +356,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) { ...@@ -356,7 +356,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset); tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
} }
free(charset); taosMemoryFree(charset);
} else { // it may be windows system } else { // it may be windows system
tscInfo("charset remains:%s", tsCharset); tscInfo("charset remains:%s", tsCharset);
} }
......
...@@ -166,7 +166,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { ...@@ -166,7 +166,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) { static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) {
static int32_t emptyRspNum = 0; static int32_t emptyRspNum = 0;
if (code != 0) { if (code != 0) {
tfree(param); taosMemoryFreeClear(param);
return -1; return -1;
} }
...@@ -179,12 +179,12 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) ...@@ -179,12 +179,12 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code)
SAppInstInfo **pInst = taosHashGet(appInfo.pInstMap, key, strlen(key)); SAppInstInfo **pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
if (pInst == NULL || NULL == *pInst) { if (pInst == NULL || NULL == *pInst) {
tscError("cluster not exist, key:%s", key); tscError("cluster not exist, key:%s", key);
tfree(param); taosMemoryFreeClear(param);
tFreeClientHbBatchRsp(&pRsp); tFreeClientHbBatchRsp(&pRsp);
return -1; return -1;
} }
tfree(param); taosMemoryFreeClear(param);
if (rspNum) { if (rspNum) {
tscDebug("hb got %d rsp, %d empty rsp received before", rspNum, tscDebug("hb got %d rsp, %d empty rsp received before", rspNum,
...@@ -317,7 +317,7 @@ void hbFreeReq(void *req) { ...@@ -317,7 +317,7 @@ void hbFreeReq(void *req) {
} }
SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
SClientHbBatchReq *pBatchReq = calloc(1, sizeof(SClientHbBatchReq)); SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq));
if (pBatchReq == NULL) { if (pBatchReq == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -346,7 +346,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { ...@@ -346,7 +346,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
if (code) { if (code) {
taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
tfree(pBatchReq); taosMemoryFreeClear(pBatchReq);
} }
return pBatchReq; return pBatchReq;
...@@ -387,7 +387,7 @@ static void *hbThreadFunc(void *param) { ...@@ -387,7 +387,7 @@ static void *hbThreadFunc(void *param) {
continue; continue;
} }
int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq); int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq);
void *buf = malloc(tlen); void *buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq, false); tFreeClientHbBatchReq(pReq, false);
...@@ -396,13 +396,13 @@ static void *hbThreadFunc(void *param) { ...@@ -396,13 +396,13 @@ static void *hbThreadFunc(void *param) {
} }
tSerializeSClientHbBatchReq(buf, tlen, pReq); tSerializeSClientHbBatchReq(buf, tlen, pReq);
SMsgSendInfo *pInfo = calloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pInfo == NULL) { if (pInfo == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq, false); tFreeClientHbBatchReq(pReq, false);
hbClearReqInfo(pAppHbMgr); hbClearReqInfo(pAppHbMgr);
free(buf); taosMemoryFree(buf);
break; break;
} }
pInfo->fp = hbAsyncCallBack; pInfo->fp = hbAsyncCallBack;
...@@ -458,7 +458,7 @@ static void hbStopThread() { ...@@ -458,7 +458,7 @@ static void hbStopThread() {
SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
hbMgrInit(); hbMgrInit();
SAppHbMgr *pAppHbMgr = malloc(sizeof(SAppHbMgr)); SAppHbMgr *pAppHbMgr = taosMemoryMalloc(sizeof(SAppHbMgr));
if (pAppHbMgr == NULL) { if (pAppHbMgr == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -478,7 +478,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { ...@@ -478,7 +478,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
if (pAppHbMgr->activeInfo == NULL) { if (pAppHbMgr->activeInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
free(pAppHbMgr); taosMemoryFree(pAppHbMgr);
return NULL; return NULL;
} }
...@@ -488,7 +488,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { ...@@ -488,7 +488,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
if (pAppHbMgr->connInfo == NULL) { if (pAppHbMgr->connInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
free(pAppHbMgr); taosMemoryFree(pAppHbMgr);
return NULL; return NULL;
} }
...@@ -580,7 +580,7 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int3 ...@@ -580,7 +580,7 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int3
switch (hbType) { switch (hbType) {
case HEARTBEAT_TYPE_QUERY: { case HEARTBEAT_TYPE_QUERY: {
int64_t *pClusterId = malloc(sizeof(int64_t)); int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t));
*pClusterId = clusterId; *pClusterId = clusterId;
info.param = pClusterId; info.param = pClusterId;
......
...@@ -100,7 +100,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, ...@@ -100,7 +100,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
pInst = taosHashGet(appInfo.pInstMap, key, strlen(key)); pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
SAppInstInfo* p = NULL; SAppInstInfo* p = NULL;
if (pInst == NULL) { if (pInst == NULL) {
p = calloc(1, sizeof(struct SAppInstInfo)); p = taosMemoryCalloc(1, sizeof(struct SAppInstInfo));
p->mgmtEp = epSet; p->mgmtEp = epSet;
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores); p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
p->pAppHbMgr = appHbMgrInit(p, key); p->pAppHbMgr = appHbMgrInit(p, key);
...@@ -111,7 +111,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, ...@@ -111,7 +111,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
taosThreadMutexUnlock(&appInfo.mutex); taosThreadMutexUnlock(&appInfo.mutex);
tfree(key); taosMemoryFreeClear(key);
return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst); return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst);
} }
...@@ -122,7 +122,7 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* ...@@ -122,7 +122,7 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
(*pRequest)->sqlstr = malloc(sqlLen + 1); (*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1);
if ((*pRequest)->sqlstr == NULL) { if ((*pRequest)->sqlstr == NULL) {
tscError("0x%" PRIx64 " failed to prepare sql string buffer", (*pRequest)->self); tscError("0x%" PRIx64 " failed to prepare sql string buffer", (*pRequest)->self);
(*pRequest)->msgBuf = strdup("failed to prepare sql string buffer"); (*pRequest)->msgBuf = strdup("failed to prepare sql string buffer");
...@@ -212,7 +212,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t ...@@ -212,7 +212,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
assert(pSchema != NULL && numOfCols > 0); assert(pSchema != NULL && numOfCols > 0);
pResInfo->numOfCols = numOfCols; pResInfo->numOfCols = numOfCols;
pResInfo->fields = calloc(numOfCols, sizeof(pSchema[0])); pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(pSchema[0]));
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) { for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
pResInfo->fields[i].bytes = pSchema[i].bytes; pResInfo->fields[i].bytes = pSchema[i].bytes;
...@@ -421,7 +421,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t ...@@ -421,7 +421,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
} }
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) { static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pMsgSendInfo == NULL) { if (pMsgSendInfo == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -441,14 +441,14 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) { ...@@ -441,14 +441,14 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
if (db != NULL) { if (db != NULL) {
tstrncpy(connectReq.db, db, sizeof(connectReq.db)); tstrncpy(connectReq.db, db, sizeof(connectReq.db));
} }
tfree(db); taosMemoryFreeClear(db);
connectReq.pid = htonl(appInfo.pid); connectReq.pid = htonl(appInfo.pid);
connectReq.startTime = htobe64(appInfo.startTime); connectReq.startTime = htobe64(appInfo.startTime);
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app)); tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
void* pReq = malloc(contLen); void* pReq = taosMemoryMalloc(contLen);
tSerializeSConnectReq(pReq, contLen, &connectReq); tSerializeSConnectReq(pReq, contLen, &connectReq);
pMsgSendInfo->msgInfo.len = contLen; pMsgSendInfo->msgInfo.len = contLen;
...@@ -458,8 +458,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) { ...@@ -458,8 +458,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
assert(pMsgBody != NULL); assert(pMsgBody != NULL);
tfree(pMsgBody->msgInfo.pData); taosMemoryFreeClear(pMsgBody->msgInfo.pData);
tfree(pMsgBody); taosMemoryFreeClear(pMsgBody);
} }
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) { bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) {
return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP || msgType == TDMT_VND_QUERY_HEARTBEAT_RSP; return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP || msgType == TDMT_VND_QUERY_HEARTBEAT_RSP;
...@@ -500,7 +500,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { ...@@ -500,7 +500,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->handle}; SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->handle};
if (pMsg->contLen > 0) { if (pMsg->contLen > 0) {
buf.pData = calloc(1, pMsg->contLen); buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) { if (buf.pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
pMsg->code = TSDB_CODE_OUT_OF_MEMORY; pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
...@@ -592,7 +592,7 @@ void* doFetchRow(SRequestObj* pRequest) { ...@@ -592,7 +592,7 @@ void* doFetchRow(SRequestObj* pRequest) {
} }
SVgroupInfo* pVgroupInfo = taosArrayGet(pShowReqInfo->pArray, pShowReqInfo->currentIndex); SVgroupInfo* pVgroupInfo = taosArrayGet(pShowReqInfo->pArray, pShowReqInfo->currentIndex);
SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq)); SVShowTablesReq* pShowReq = taosMemoryCalloc(1, sizeof(SVShowTablesReq));
pShowReq->head.vgId = htonl(pVgroupInfo->vgId); pShowReq->head.vgId = htonl(pVgroupInfo->vgId);
pRequest->body.requestMsg.len = sizeof(SVShowTablesReq); pRequest->body.requestMsg.len = sizeof(SVShowTablesReq);
...@@ -670,10 +670,10 @@ _return: ...@@ -670,10 +670,10 @@ _return:
static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
if (pResInfo->row == NULL) { if (pResInfo->row == NULL) {
pResInfo->row = calloc(pResInfo->numOfCols, POINTER_BYTES); pResInfo->row = taosMemoryCalloc(pResInfo->numOfCols, POINTER_BYTES);
pResInfo->pCol = calloc(pResInfo->numOfCols, sizeof(SResultColumn)); pResInfo->pCol = taosMemoryCalloc(pResInfo->numOfCols, sizeof(SResultColumn));
pResInfo->length = calloc(pResInfo->numOfCols, sizeof(int32_t)); pResInfo->length = taosMemoryCalloc(pResInfo->numOfCols, sizeof(int32_t));
pResInfo->convertBuf = calloc(pResInfo->numOfCols, POINTER_BYTES); pResInfo->convertBuf = taosMemoryCalloc(pResInfo->numOfCols, POINTER_BYTES);
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) { if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
...@@ -681,7 +681,7 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { ...@@ -681,7 +681,7 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
for(int32_t i = 0; i < pResInfo->numOfCols; ++i) { for(int32_t i = 0; i < pResInfo->numOfCols; ++i) {
if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) { if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) {
pResInfo->convertBuf[i] = calloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes)); pResInfo->convertBuf[i] = taosMemoryCalloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes));
} }
} }
} }
......
...@@ -32,7 +32,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -32,7 +32,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param; SRequestObj* pRequest = param;
setErrno(pRequest, code); setErrno(pRequest, code);
free(pMsg->pData); taosMemoryFree(pMsg->pData);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
return code; return code;
} }
...@@ -40,7 +40,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -40,7 +40,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param; SRequestObj* pRequest = param;
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
free(pMsg->pData); taosMemoryFree(pMsg->pData);
setErrno(pRequest, code); setErrno(pRequest, code);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
return code; return code;
...@@ -77,13 +77,13 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -77,13 +77,13 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId, tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
pTscObj->pAppInfo->numOfConns); pTscObj->pAppInfo->numOfConns);
free(pMsg->pData); taosMemoryFree(pMsg->pData);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
return 0; return 0;
} }
SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) { SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
pMsgSendInfo->requestObjRefId = pRequest->self; pMsgSendInfo->requestObjRefId = pRequest->self;
pMsgSendInfo->requestId = pRequest->requestId; pMsgSendInfo->requestId = pRequest->requestId;
...@@ -96,13 +96,13 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) { ...@@ -96,13 +96,13 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
retrieveReq.showId = pRequest->body.showInfo.execId; retrieveReq.showId = pRequest->body.showInfo.execId;
int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq); int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq);
void* pReq = malloc(contLen); void* pReq = taosMemoryMalloc(contLen);
tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq); tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq);
pMsgSendInfo->msgInfo.pData = pReq; pMsgSendInfo->msgInfo.pData = pReq;
pMsgSendInfo->msgInfo.len = contLen; pMsgSendInfo->msgInfo.len = contLen;
pMsgSendInfo->msgInfo.handle = NULL; pMsgSendInfo->msgInfo.handle = NULL;
} else { } else {
SVShowTablesFetchReq* pFetchMsg = calloc(1, sizeof(SVShowTablesFetchReq)); SVShowTablesFetchReq* pFetchMsg = taosMemoryCalloc(1, sizeof(SVShowTablesFetchReq));
if (pFetchMsg == NULL) { if (pFetchMsg == NULL) {
return NULL; return NULL;
} }
...@@ -135,12 +135,12 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -135,12 +135,12 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
tDeserializeSShowRsp(pMsg->pData, pMsg->len, &showRsp); tDeserializeSShowRsp(pMsg->pData, pMsg->len, &showRsp);
STableMetaRsp *pMetaMsg = &showRsp.tableMeta; STableMetaRsp *pMetaMsg = &showRsp.tableMeta;
tfree(pRequest->body.resInfo.pRspMsg); taosMemoryFreeClear(pRequest->body.resInfo.pRspMsg);
pRequest->body.resInfo.pRspMsg = pMsg->pData; pRequest->body.resInfo.pRspMsg = pMsg->pData;
SReqResultInfo* pResInfo = &pRequest->body.resInfo; SReqResultInfo* pResInfo = &pRequest->body.resInfo;
if (pResInfo->fields == NULL) { if (pResInfo->fields == NULL) {
TAOS_FIELD* pFields = calloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD)); TAOS_FIELD* pFields = taosMemoryCalloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) { for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
SSchema* pSchema = &pMetaMsg->pSchemas[i]; SSchema* pSchema = &pMetaMsg->pSchemas[i];
tstrncpy(pFields[i].name, pSchema->name, tListLen(pFields[i].name)); tstrncpy(pFields[i].name, pSchema->name, tListLen(pFields[i].name));
...@@ -171,7 +171,7 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -171,7 +171,7 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) { int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj *pRequest = param; SRequestObj *pRequest = param;
SReqResultInfo *pResInfo = &pRequest->body.resInfo; SReqResultInfo *pResInfo = &pRequest->body.resInfo;
tfree(pResInfo->pRspMsg); taosMemoryFreeClear(pResInfo->pRspMsg);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code); setErrno(pRequest, code);
...@@ -204,7 +204,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -204,7 +204,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param; SRequestObj* pRequest = param;
SReqResultInfo* pResInfo = &pRequest->body.resInfo; SReqResultInfo* pResInfo = &pRequest->body.resInfo;
tfree(pResInfo->pRspMsg); taosMemoryFreeClear(pResInfo->pRspMsg);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code); setErrno(pRequest, code);
...@@ -237,7 +237,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -237,7 +237,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) {
int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
// todo rsp with the vnode id list // todo rsp with the vnode id list
SRequestObj* pRequest = param; SRequestObj* pRequest = param;
free(pMsg->pData); taosMemoryFree(pMsg->pData);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code); setErrno(pRequest, code);
} }
...@@ -266,7 +266,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -266,7 +266,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
} }
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
free(pMsg->pData); taosMemoryFree(pMsg->pData);
setErrno(pRequest, code); setErrno(pRequest, code);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
return code; return code;
...@@ -284,7 +284,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -284,7 +284,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
if (code != 0) { if (code != 0) {
terrno = code; terrno = code;
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash); if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
tfree(output.dbVgroup); taosMemoryFreeClear(output.dbVgroup);
tscError("failed to build use db output since %s", terrstr()); tscError("failed to build use db output since %s", terrstr());
} else { } else {
...@@ -304,7 +304,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -304,7 +304,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
tNameGetDbName(&name, db); tNameGetDbName(&name, db);
setConnectionDB(pRequest->pTscObj, db); setConnectionDB(pRequest->pTscObj, db);
free(pMsg->pData); taosMemoryFree(pMsg->pData);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
return 0; return 0;
} }
...@@ -313,7 +313,7 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -313,7 +313,7 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
assert(pMsg != NULL && param != NULL); assert(pMsg != NULL && param != NULL);
SRequestObj* pRequest = param; SRequestObj* pRequest = param;
free(pMsg->pData); taosMemoryFree(pMsg->pData);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code); setErrno(pRequest, code);
tsem_post(&pRequest->body.rspSem); tsem_post(&pRequest->body.rspSem);
......
...@@ -136,14 +136,14 @@ typedef struct { ...@@ -136,14 +136,14 @@ typedef struct {
} SMqCommitCbParam; } SMqCommitCbParam;
tmq_conf_t* tmq_conf_new() { tmq_conf_t* tmq_conf_new() {
tmq_conf_t* conf = calloc(1, sizeof(tmq_conf_t)); tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t));
conf->auto_commit = false; conf->auto_commit = false;
conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST; conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST;
return conf; return conf;
} }
void tmq_conf_destroy(tmq_conf_t* conf) { void tmq_conf_destroy(tmq_conf_t* conf) {
if (conf) free(conf); if (conf) taosMemoryFree(conf);
} }
tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) { tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) {
...@@ -184,7 +184,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value ...@@ -184,7 +184,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
} }
tmq_list_t* tmq_list_new() { tmq_list_t* tmq_list_new() {
tmq_list_t* ptr = malloc(sizeof(tmq_list_t) + 8 * sizeof(char*)); tmq_list_t* ptr = taosMemoryMalloc(sizeof(tmq_list_t) + 8 * sizeof(char*));
if (ptr == NULL) { if (ptr == NULL) {
return ptr; return ptr;
} }
...@@ -254,7 +254,7 @@ tmq_resp_err_t tmq_unsubscribe(tmq_t* tmq) { ...@@ -254,7 +254,7 @@ tmq_resp_err_t tmq_unsubscribe(tmq_t* tmq) {
} }
tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errstrLen) { tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
tmq_t* pTmq = calloc(sizeof(tmq_t), 1); tmq_t* pTmq = taosMemoryCalloc(sizeof(tmq_t), 1);
if (pTmq == NULL) { if (pTmq == NULL) {
return NULL; return NULL;
} }
...@@ -317,7 +317,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in ...@@ -317,7 +317,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
tEncodeSMqCMCommitOffsetReq(&encoder, &req); tEncodeSMqCMCommitOffsetReq(&encoder, &req);
int32_t tlen = encoder.pos; int32_t tlen = encoder.pos;
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
tCoderClear(&encoder); tCoderClear(&encoder);
return -1; return -1;
...@@ -333,7 +333,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in ...@@ -333,7 +333,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
tscError("failed to malloc request"); tscError("failed to malloc request");
} }
SMqCommitCbParam* pParam = malloc(sizeof(SMqCommitCbParam)); SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
if (pParam == NULL) { if (pParam == NULL) {
return -1; return -1;
} }
...@@ -361,7 +361,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in ...@@ -361,7 +361,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
} }
tsem_destroy(&pParam->rspSem); tsem_destroy(&pParam->rspSem);
free(pParam); taosMemoryFree(pParam);
if (pArray) { if (pArray) {
taosArrayDestroy(pArray); taosArrayDestroy(pArray);
...@@ -394,7 +394,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) { ...@@ -394,7 +394,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
tNameSetDbName(&name, tmq->pTscObj->acctId, dbName, strlen(dbName)); tNameSetDbName(&name, tmq->pTscObj->acctId, dbName, strlen(dbName));
tNameFromString(&name, topicName, T_NAME_TABLE); tNameFromString(&name, topicName, T_NAME_TABLE);
char* topicFname = calloc(1, TSDB_TOPIC_FNAME_LEN); char* topicFname = taosMemoryCalloc(1, TSDB_TOPIC_FNAME_LEN);
if (topicFname == NULL) { if (topicFname == NULL) {
goto _return; goto _return;
} }
...@@ -405,11 +405,11 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) { ...@@ -405,11 +405,11 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
topic.vgs = taosArrayInit(0, sizeof(SMqClientVg)); topic.vgs = taosArrayInit(0, sizeof(SMqClientVg));
taosArrayPush(tmq->clientTopics, &topic); taosArrayPush(tmq->clientTopics, &topic);
taosArrayPush(req.topicNames, &topicFname); taosArrayPush(req.topicNames, &topicFname);
free(dbName); taosMemoryFree(dbName);
} }
int tlen = tSerializeSCMSubscribeReq(NULL, &req); int tlen = tSerializeSCMSubscribeReq(NULL, &req);
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
goto _return; goto _return;
} }
...@@ -508,7 +508,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa ...@@ -508,7 +508,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
strcpy(req.outputSTbName, tbName); strcpy(req.outputSTbName, tbName);
int tlen = tSerializeSCMCreateStreamReq(NULL, 0, &req); int tlen = tSerializeSCMCreateStreamReq(NULL, 0, &req);
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
goto _return; goto _return;
} }
...@@ -532,7 +532,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa ...@@ -532,7 +532,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
tsem_wait(&pRequest->body.rspSem); tsem_wait(&pRequest->body.rspSem);
_return: _return:
tfree(astStr); taosMemoryFreeClear(astStr);
qDestroyQuery(pQueryNode); qDestroyQuery(pQueryNode);
/*if (sendInfo != NULL) {*/ /*if (sendInfo != NULL) {*/
/*destroySendMsgInfo(sendInfo);*/ /*destroySendMsgInfo(sendInfo);*/
...@@ -594,7 +594,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i ...@@ -594,7 +594,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
tNameExtractFullName(&name, req.name); tNameExtractFullName(&name, req.name);
int tlen = tSerializeSCMCreateTopicReq(NULL, 0, &req); int tlen = tSerializeSCMCreateTopicReq(NULL, 0, &req);
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
goto _return; goto _return;
} }
...@@ -618,7 +618,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i ...@@ -618,7 +618,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
tsem_wait(&pRequest->body.rspSem); tsem_wait(&pRequest->body.rspSem);
_return: _return:
tfree(astStr); taosMemoryFreeClear(astStr);
qDestroyQuery(pQueryNode); qDestroyQuery(pQueryNode);
/*if (sendInfo != NULL) {*/ /*if (sendInfo != NULL) {*/
/*destroySendMsgInfo(sendInfo);*/ /*destroySendMsgInfo(sendInfo);*/
...@@ -757,7 +757,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -757,7 +757,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
#if 0 #if 0
if (pParam->sync == 1) { if (pParam->sync == 1) {
/**pParam->msg = malloc(sizeof(tmq_message_t));*/ /**pParam->msg = taosMemoryMalloc(sizeof(tmq_message_t));*/
*pParam->msg = taosAllocateQitem(sizeof(tmq_message_t)); *pParam->msg = taosAllocateQitem(sizeof(tmq_message_t));
if (*pParam->msg) { if (*pParam->msg) {
memcpy(*pParam->msg, pMsg->pData, sizeof(SMqRspHead)); memcpy(*pParam->msg, pMsg->pData, sizeof(SMqRspHead));
...@@ -774,7 +774,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -774,7 +774,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
} }
#endif #endif
/*SMqConsumeRsp* pRsp = calloc(1, sizeof(SMqConsumeRsp));*/ /*SMqConsumeRsp* pRsp = taosMemoryCalloc(1, sizeof(SMqConsumeRsp));*/
tmq_message_t* pRsp = taosAllocateQitem(sizeof(tmq_message_t)); tmq_message_t* pRsp = taosAllocateQitem(sizeof(tmq_message_t));
if (pRsp == NULL) { if (pRsp == NULL) {
goto WRITE_QUEUE_FAIL; goto WRITE_QUEUE_FAIL;
...@@ -884,7 +884,7 @@ END: ...@@ -884,7 +884,7 @@ END:
int32_t tmqAskEp(tmq_t* tmq, bool sync) { int32_t tmqAskEp(tmq_t* tmq, bool sync) {
int32_t tlen = sizeof(SMqCMGetSubEpReq); int32_t tlen = sizeof(SMqCMGetSubEpReq);
SMqCMGetSubEpReq* req = malloc(tlen); SMqCMGetSubEpReq* req = taosMemoryMalloc(tlen);
if (req == NULL) { if (req == NULL) {
tscError("failed to malloc get subscribe ep buf"); tscError("failed to malloc get subscribe ep buf");
return -1; return -1;
...@@ -893,21 +893,21 @@ int32_t tmqAskEp(tmq_t* tmq, bool sync) { ...@@ -893,21 +893,21 @@ int32_t tmqAskEp(tmq_t* tmq, bool sync) {
req->epoch = htonl(tmq->epoch); req->epoch = htonl(tmq->epoch);
strcpy(req->cgroup, tmq->groupId); strcpy(req->cgroup, tmq->groupId);
SMqAskEpCbParam* pParam = malloc(sizeof(SMqAskEpCbParam)); SMqAskEpCbParam* pParam = taosMemoryMalloc(sizeof(SMqAskEpCbParam));
if (pParam == NULL) { if (pParam == NULL) {
tscError("failed to malloc subscribe param"); tscError("failed to malloc subscribe param");
free(req); taosMemoryFree(req);
return -1; return -1;
} }
pParam->tmq = tmq; pParam->tmq = tmq;
pParam->sync = sync; pParam->sync = sync;
tsem_init(&pParam->rspSem, 0, 0); tsem_init(&pParam->rspSem, 0, 0);
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo)); SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
if (sendInfo == NULL) { if (sendInfo == NULL) {
tsem_destroy(&pParam->rspSem); tsem_destroy(&pParam->rspSem);
free(pParam); taosMemoryFree(pParam);
free(req); taosMemoryFree(req);
return -1; return -1;
} }
...@@ -967,7 +967,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClientTo ...@@ -967,7 +967,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClientTo
reqOffset = tmq->resetOffsetCfg; reqOffset = tmq->resetOffsetCfg;
} }
SMqPollReq* pReq = malloc(sizeof(SMqPollReq)); SMqPollReq* pReq = taosMemoryMalloc(sizeof(SMqPollReq));
if (pReq == NULL) { if (pReq == NULL) {
return NULL; return NULL;
} }
...@@ -1003,7 +1003,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) { ...@@ -1003,7 +1003,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) {
return NULL; return NULL;
} }
SMqPollCbParam* pParam = malloc(sizeof(SMqPollCbParam)); SMqPollCbParam* pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
if (pParam == NULL) { if (pParam == NULL) {
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
// TODO: out of mem // TODO: out of mem
...@@ -1016,7 +1016,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) { ...@@ -1016,7 +1016,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) {
pParam->msg = &msg; pParam->msg = &msg;
tsem_init(&pParam->rspSem, 0, 0); tsem_init(&pParam->rspSem, 0, 0);
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo)); SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
if (sendInfo == NULL) { if (sendInfo == NULL) {
return NULL; return NULL;
} }
...@@ -1071,9 +1071,9 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) { ...@@ -1071,9 +1071,9 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
tsem_post(&tmq->rspSem); tsem_post(&tmq->rspSem);
return -1; return -1;
} }
SMqPollCbParam* pParam = malloc(sizeof(SMqPollCbParam)); SMqPollCbParam* pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
if (pParam == NULL) { if (pParam == NULL) {
free(pReq); taosMemoryFree(pReq);
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
tsem_post(&tmq->rspSem); tsem_post(&tmq->rspSem);
return -1; return -1;
...@@ -1083,10 +1083,10 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) { ...@@ -1083,10 +1083,10 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
pParam->epoch = tmq->epoch; pParam->epoch = tmq->epoch;
pParam->sync = 0; pParam->sync = 0;
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo)); SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
if (sendInfo == NULL) { if (sendInfo == NULL) {
free(pReq); taosMemoryFree(pReq);
free(pParam); taosMemoryFree(pParam);
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
tsem_post(&tmq->rspSem); tsem_post(&tmq->rspSem);
return -1; return -1;
...@@ -1258,7 +1258,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) { ...@@ -1258,7 +1258,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
return NULL; return NULL;
} }
SMqPollCbParam* param = malloc(sizeof(SMqPollCbParam)); SMqPollCbParam* param = taosMemoryMalloc(sizeof(SMqPollCbParam));
if (param == NULL) { if (param == NULL) {
ASSERT(false); ASSERT(false);
taosMsleep(blocking_time); taosMsleep(blocking_time);
...@@ -1289,7 +1289,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) { ...@@ -1289,7 +1289,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
tsem_wait(&param->rspSem); tsem_wait(&param->rspSem);
tsem_destroy(&param->rspSem); tsem_destroy(&param->rspSem);
free(param); taosMemoryFree(param);
if (tmq_message == NULL) { if (tmq_message == NULL) {
if (beginVgIdx == pTopic->nextVgIdx) { if (beginVgIdx == pTopic->nextVgIdx) {
...@@ -1331,7 +1331,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_v ...@@ -1331,7 +1331,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_v
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME); SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)}; pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
SMqCommitCbParam* pParam = malloc(sizeof(SMqCommitCbParam)); SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
if (pParam == NULL) { if (pParam == NULL) {
continue; continue;
} }
...@@ -1360,7 +1360,7 @@ void tmq_message_destroy(tmq_message_t* tmq_message) { ...@@ -1360,7 +1360,7 @@ void tmq_message_destroy(tmq_message_t* tmq_message) {
if (tmq_message == NULL) return; if (tmq_message == NULL) return;
SMqPollRsp* pRsp = &tmq_message->msg; SMqPollRsp* pRsp = &tmq_message->msg;
tDeleteSMqConsumeRsp(pRsp); tDeleteSMqConsumeRsp(pRsp);
/*free(tmq_message);*/ /*taosMemoryFree(tmq_message);*/
taosFreeQitem(tmq_message); taosFreeQitem(tmq_message);
} }
...@@ -1403,7 +1403,7 @@ char* tmq_get_topic_name(tmq_message_t* message) { return "not implemented yet"; ...@@ -1403,7 +1403,7 @@ char* tmq_get_topic_name(tmq_message_t* message) { return "not implemented yet";
#if 0 #if 0
tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) { tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) {
tmq_t* pTmq = malloc(sizeof(tmq_t)); tmq_t* pTmq = taosMemoryMalloc(sizeof(tmq_t));
if (pTmq == NULL) { if (pTmq == NULL) {
return NULL; return NULL;
} }
...@@ -1417,7 +1417,7 @@ tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) { ...@@ -1417,7 +1417,7 @@ tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) {
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
assert(pMsgBody != NULL); assert(pMsgBody != NULL);
tfree(pMsgBody->msgInfo.pData); taosMemoryFreeClear(pMsgBody->msgInfo.pData);
tfree(pMsgBody); taosMemoryFreeClear(pMsgBody);
} }
#endif #endif
...@@ -115,7 +115,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con ...@@ -115,7 +115,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
newSize = newSize * 1.5; newSize = newSize * 1.5;
} }
char* buf = realloc(pColumnInfoData->pData, newSize); char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -178,7 +178,7 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c ...@@ -178,7 +178,7 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
uint32_t total = numOfRow1 + numOfRow2; uint32_t total = numOfRow1 + numOfRow2;
if (BitmapLen(numOfRow1) < BitmapLen(total)) { if (BitmapLen(numOfRow1) < BitmapLen(total)) {
char* tmp = realloc(pColumnInfoData->nullbitmap, BitmapLen(total)); char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(total));
uint32_t extend = BitmapLen(total) - BitmapLen(numOfRow1); uint32_t extend = BitmapLen(total) - BitmapLen(numOfRow1);
memset(tmp + BitmapLen(numOfRow1), 0, extend); memset(tmp + BitmapLen(numOfRow1), 0, extend);
pColumnInfoData->nullbitmap = tmp; pColumnInfoData->nullbitmap = tmp;
...@@ -218,7 +218,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co ...@@ -218,7 +218,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
// Handle the bitmap // Handle the bitmap
char* p = realloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2)); char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
if (p == NULL) { if (p == NULL) {
// TODO // TODO
} }
...@@ -232,7 +232,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co ...@@ -232,7 +232,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
uint32_t len = pSource->varmeta.length; uint32_t len = pSource->varmeta.length;
uint32_t oldLen = pColumnInfoData->varmeta.length; uint32_t oldLen = pColumnInfoData->varmeta.length;
if (pColumnInfoData->varmeta.allocLen < len + oldLen) { if (pColumnInfoData->varmeta.allocLen < len + oldLen) {
char* tmp = realloc(pColumnInfoData->pData, len + oldLen); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, len + oldLen);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_VND_OUT_OF_MEMORY; return TSDB_CODE_VND_OUT_OF_MEMORY;
} }
...@@ -247,7 +247,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co ...@@ -247,7 +247,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2); doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2);
int32_t newSize = (numOfRow1 + numOfRow2) * pColumnInfoData->info.bytes; int32_t newSize = (numOfRow1 + numOfRow2) * pColumnInfoData->info.bytes;
char* tmp = realloc(pColumnInfoData->pData, newSize); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_VND_OUT_OF_MEMORY; return TSDB_CODE_VND_OUT_OF_MEMORY;
} }
...@@ -268,7 +268,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p ...@@ -268,7 +268,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
// Handle the bitmap // Handle the bitmap
char* p = realloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * numOfRows); char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * numOfRows);
if (p == NULL) { if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -277,7 +277,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p ...@@ -277,7 +277,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
memcpy(pColumnInfoData->varmeta.offset, pSource->varmeta.offset, sizeof(int32_t) * numOfRows); memcpy(pColumnInfoData->varmeta.offset, pSource->varmeta.offset, sizeof(int32_t) * numOfRows);
if (pColumnInfoData->varmeta.allocLen < pSource->varmeta.length) { if (pColumnInfoData->varmeta.allocLen < pSource->varmeta.length) {
char* tmp = realloc(pColumnInfoData->pData, pSource->varmeta.length); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, pSource->varmeta.length);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -289,7 +289,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p ...@@ -289,7 +289,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length); memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length);
pColumnInfoData->varmeta.length = pSource->varmeta.length; pColumnInfoData->varmeta.length = pSource->varmeta.length;
} else { } else {
char* tmp = realloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows)); char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows));
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -298,7 +298,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p ...@@ -298,7 +298,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows)); memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows));
int32_t newSize = numOfRows * pColumnInfoData->info.bytes; int32_t newSize = numOfRows * pColumnInfoData->info.bytes;
tmp = realloc(pColumnInfoData->pData, newSize); tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -349,7 +349,7 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) { ...@@ -349,7 +349,7 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) {
uint32_t newLen = colDataGetLength(pCol1, pSrc->info.rows); uint32_t newLen = colDataGetLength(pCol1, pSrc->info.rows);
int32_t newSize = oldLen + newLen; int32_t newSize = oldLen + newLen;
char* tmp = realloc(pCol2->pData, newSize); char* tmp = taosMemoryRealloc(pCol2->pData, newSize);
if (tmp != NULL) { if (tmp != NULL) {
pCol2->pData = tmp; pCol2->pData = tmp;
colDataMergeCol(pCol2, pDest->info.rows, pCol1, pSrc->info.rows); colDataMergeCol(pCol2, pDest->info.rows, pCol1, pSrc->info.rows);
...@@ -453,7 +453,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3 ...@@ -453,7 +453,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
return NULL; return NULL;
} }
SSDataBlock* pDst = calloc(1, sizeof(SSDataBlock)); SSDataBlock* pDst = taosMemoryCalloc(1, sizeof(SSDataBlock));
if (pDst == NULL) { if (pDst == NULL) {
return NULL; return NULL;
} }
...@@ -470,10 +470,10 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3 ...@@ -470,10 +470,10 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
if (IS_VAR_DATA_TYPE(pSrcCol->info.type)) { if (IS_VAR_DATA_TYPE(pSrcCol->info.type)) {
SVarColAttr* pAttr = &colInfo.varmeta; SVarColAttr* pAttr = &colInfo.varmeta;
pAttr->offset = calloc(rowCount, sizeof(int32_t)); pAttr->offset = taosMemoryCalloc(rowCount, sizeof(int32_t));
} else { } else {
colInfo.nullbitmap = calloc(1, BitmapLen(rowCount)); colInfo.nullbitmap = taosMemoryCalloc(1, BitmapLen(rowCount));
colInfo.pData = calloc(rowCount, colInfo.info.bytes); colInfo.pData = taosMemoryCalloc(rowCount, colInfo.info.bytes);
} }
taosArrayPush(pDst->pDataBlock, &colInfo); taosArrayPush(pDst->pDataBlock, &colInfo);
...@@ -562,7 +562,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { ...@@ -562,7 +562,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
if (IS_VAR_DATA_TYPE(pCol->info.type)) { if (IS_VAR_DATA_TYPE(pCol->info.type)) {
if (pCol->varmeta.allocLen < colLength) { if (pCol->varmeta.allocLen < colLength) {
char* tmp = realloc(pCol->pData, colLength); char* tmp = taosMemoryRealloc(pCol->pData, colLength);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -610,7 +610,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) { ...@@ -610,7 +610,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) {
} }
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols) { SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols) {
SSchema* pSchema = calloc(pBlock->info.numOfCols, sizeof(SSchema)); SSchema* pSchema = taosMemoryCalloc(pBlock->info.numOfCols, sizeof(SSchema));
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
pSchema[i].bytes = pColInfoData->info.bytes; pSchema[i].bytes = pColInfoData->info.bytes;
...@@ -819,7 +819,7 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) { ...@@ -819,7 +819,7 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) {
int32_t rows = pDataBlock->info.rows; int32_t rows = pDataBlock->info.rows;
int32_t numOfCols = pDataBlock->info.numOfCols; int32_t numOfCols = pDataBlock->info.numOfCols;
SColumnInfoData* pCols = calloc(numOfCols, sizeof(SColumnInfoData)); SColumnInfoData* pCols = taosMemoryCalloc(numOfCols, sizeof(SColumnInfoData));
if (pCols == NULL) { if (pCols == NULL) {
return NULL; return NULL;
} }
...@@ -829,14 +829,14 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) { ...@@ -829,14 +829,14 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) {
pCols[i].info = pColInfoData->info; pCols[i].info = pColInfoData->info;
if (IS_VAR_DATA_TYPE(pCols[i].info.type)) { if (IS_VAR_DATA_TYPE(pCols[i].info.type)) {
pCols[i].varmeta.offset = calloc(rows, sizeof(int32_t)); pCols[i].varmeta.offset = taosMemoryCalloc(rows, sizeof(int32_t));
pCols[i].pData = calloc(1, pColInfoData->varmeta.length); pCols[i].pData = taosMemoryCalloc(1, pColInfoData->varmeta.length);
pCols[i].varmeta.length = pColInfoData->varmeta.length; pCols[i].varmeta.length = pColInfoData->varmeta.length;
pCols[i].varmeta.allocLen = pCols[i].varmeta.length; pCols[i].varmeta.allocLen = pCols[i].varmeta.length;
} else { } else {
pCols[i].nullbitmap = calloc(1, BitmapLen(rows)); pCols[i].nullbitmap = taosMemoryCalloc(1, BitmapLen(rows));
pCols[i].pData = calloc(rows, pCols[i].info.bytes); pCols[i].pData = taosMemoryCalloc(rows, pCols[i].info.bytes);
} }
} }
...@@ -851,22 +851,22 @@ static void copyBackToBlock(SSDataBlock* pDataBlock, SColumnInfoData* pCols) { ...@@ -851,22 +851,22 @@ static void copyBackToBlock(SSDataBlock* pDataBlock, SColumnInfoData* pCols) {
pColInfoData->info = pCols[i].info; pColInfoData->info = pCols[i].info;
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
tfree(pColInfoData->varmeta.offset); taosMemoryFreeClear(pColInfoData->varmeta.offset);
pColInfoData->varmeta = pCols[i].varmeta; pColInfoData->varmeta = pCols[i].varmeta;
} else { } else {
tfree(pColInfoData->nullbitmap); taosMemoryFreeClear(pColInfoData->nullbitmap);
pColInfoData->nullbitmap = pCols[i].nullbitmap; pColInfoData->nullbitmap = pCols[i].nullbitmap;
} }
tfree(pColInfoData->pData); taosMemoryFreeClear(pColInfoData->pData);
pColInfoData->pData = pCols[i].pData; pColInfoData->pData = pCols[i].pData;
} }
tfree(pCols); taosMemoryFreeClear(pCols);
} }
static int32_t* createTupleIndex(size_t rows) { static int32_t* createTupleIndex(size_t rows) {
int32_t* index = calloc(rows, sizeof(int32_t)); int32_t* index = taosMemoryCalloc(rows, sizeof(int32_t));
if (index == NULL) { if (index == NULL) {
return NULL; return NULL;
} }
...@@ -878,7 +878,7 @@ static int32_t* createTupleIndex(size_t rows) { ...@@ -878,7 +878,7 @@ static int32_t* createTupleIndex(size_t rows) {
return index; return index;
} }
static void destroyTupleIndex(int32_t* index) { tfree(index); } static void destroyTupleIndex(int32_t* index) { taosMemoryFreeClear(index); }
static __compar_fn_t getComparFn(int32_t type, int32_t order) { static __compar_fn_t getComparFn(int32_t type, int32_t order) {
switch (type) { switch (type) {
...@@ -1019,8 +1019,8 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock* ...@@ -1019,8 +1019,8 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock*
size_t len = sortValLengthPerRow * pBlock->info.rows; size_t len = sortValLengthPerRow * pBlock->info.rows;
char* buf = calloc(1, len); char* buf = taosMemoryCalloc(1, len);
SHelper* phelper = calloc(numOfRows, sizeof(SHelper)); SHelper* phelper = taosMemoryCalloc(numOfRows, sizeof(SHelper));
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
phelper[i].index = i; phelper[i].index = i;
phelper[i].pData = buf + sortValLengthPerRow * i; phelper[i].pData = buf + sortValLengthPerRow * i;
...@@ -1163,7 +1163,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo ...@@ -1163,7 +1163,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
} }
if (IS_VAR_DATA_TYPE(pColumn->info.type)) { if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
char* tmp = realloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows); char* tmp = taosMemoryRealloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -1173,9 +1173,9 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo ...@@ -1173,9 +1173,9 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
pColumn->varmeta.length = 0; pColumn->varmeta.length = 0;
pColumn->varmeta.allocLen = 0; pColumn->varmeta.allocLen = 0;
tfree(pColumn->pData); taosMemoryFreeClear(pColumn->pData);
} else { } else {
char* tmp = realloc(pColumn->nullbitmap, BitmapLen(numOfRows)); char* tmp = taosMemoryRealloc(pColumn->nullbitmap, BitmapLen(numOfRows));
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -1183,7 +1183,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo ...@@ -1183,7 +1183,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
pColumn->nullbitmap = tmp; pColumn->nullbitmap = tmp;
memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows)); memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows));
assert(pColumn->info.bytes); assert(pColumn->info.bytes);
tmp = realloc(pColumn->pData, numOfRows * pColumn->info.bytes); tmp = taosMemoryRealloc(pColumn->pData, numOfRows * pColumn->info.bytes);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -1214,14 +1214,14 @@ void* blockDataDestroy(SSDataBlock* pBlock) { ...@@ -1214,14 +1214,14 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
} }
blockDestroyInner(pBlock); blockDestroyInner(pBlock);
tfree(pBlock); taosMemoryFreeClear(pBlock);
return NULL; return NULL;
} }
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) { SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
int32_t numOfCols = pDataBlock->info.numOfCols; int32_t numOfCols = pDataBlock->info.numOfCols;
SSDataBlock* pBlock = calloc(1, sizeof(SSDataBlock)); SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
pBlock->info.numOfCols = numOfCols; pBlock->info.numOfCols = numOfCols;
......
...@@ -37,7 +37,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) { ...@@ -37,7 +37,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
#endif #endif
if (pCol->spaceSize < spaceNeeded) { if (pCol->spaceSize < spaceNeeded) {
void *ptr = realloc(pCol->pData, spaceNeeded); void *ptr = taosMemoryRealloc(pCol->pData, spaceNeeded);
if (ptr == NULL) { if (ptr == NULL) {
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded, strerror(errno)); uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded, strerror(errno));
return -1; return -1;
...@@ -66,7 +66,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) { ...@@ -66,7 +66,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
*/ */
STSchema *tdDupSchema(const STSchema *pSchema) { STSchema *tdDupSchema(const STSchema *pSchema) {
int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema); int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema);
STSchema *tSchema = (STSchema *)malloc(tlen); STSchema *tSchema = (STSchema *)taosMemoryMalloc(tlen);
if (tSchema == NULL) return NULL; if (tSchema == NULL) return NULL;
memcpy((void *)tSchema, (void *)pSchema, tlen); memcpy((void *)tSchema, (void *)pSchema, tlen);
...@@ -127,7 +127,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { ...@@ -127,7 +127,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
if (pBuilder == NULL) return -1; if (pBuilder == NULL) return -1;
pBuilder->tCols = 256; pBuilder->tCols = 256;
pBuilder->columns = (STColumn *)malloc(sizeof(STColumn) * pBuilder->tCols); pBuilder->columns = (STColumn *)taosMemoryMalloc(sizeof(STColumn) * pBuilder->tCols);
if (pBuilder->columns == NULL) return -1; if (pBuilder->columns == NULL) return -1;
tdResetTSchemaBuilder(pBuilder, version); tdResetTSchemaBuilder(pBuilder, version);
...@@ -136,7 +136,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) { ...@@ -136,7 +136,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) { void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
if (pBuilder) { if (pBuilder) {
tfree(pBuilder->columns); taosMemoryFreeClear(pBuilder->columns);
} }
} }
...@@ -153,7 +153,7 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int1 ...@@ -153,7 +153,7 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int1
if (pBuilder->nCols >= pBuilder->tCols) { if (pBuilder->nCols >= pBuilder->tCols) {
pBuilder->tCols *= 2; pBuilder->tCols *= 2;
STColumn *columns = (STColumn *)realloc(pBuilder->columns, sizeof(STColumn) * pBuilder->tCols); STColumn *columns = (STColumn *)taosMemoryRealloc(pBuilder->columns, sizeof(STColumn) * pBuilder->tCols);
if (columns == NULL) return -1; if (columns == NULL) return -1;
pBuilder->columns = columns; pBuilder->columns = columns;
} }
...@@ -191,7 +191,7 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) { ...@@ -191,7 +191,7 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) {
int tlen = sizeof(STSchema) + sizeof(STColumn) * pBuilder->nCols; int tlen = sizeof(STSchema) + sizeof(STColumn) * pBuilder->nCols;
STSchema *pSchema = (STSchema *)malloc(tlen); STSchema *pSchema = (STSchema *)taosMemoryMalloc(tlen);
if (pSchema == NULL) return NULL; if (pSchema == NULL) return NULL;
schemaVersion(pSchema) = pBuilder->version; schemaVersion(pSchema) = pBuilder->version;
...@@ -221,7 +221,7 @@ void tdInitDataRow(SDataRow row, STSchema *pSchema) { ...@@ -221,7 +221,7 @@ void tdInitDataRow(SDataRow row, STSchema *pSchema) {
SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
int32_t size = dataRowMaxBytesFromSchema(pSchema); int32_t size = dataRowMaxBytesFromSchema(pSchema);
SDataRow row = malloc(size); SDataRow row = taosMemoryMalloc(size);
if (row == NULL) return NULL; if (row == NULL) return NULL;
tdInitDataRow(row, pSchema); tdInitDataRow(row, pSchema);
...@@ -232,11 +232,11 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) { ...@@ -232,11 +232,11 @@ 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) taosMemoryFree(row);
} }
SDataRow tdDataRowDup(SDataRow row) { SDataRow tdDataRowDup(SDataRow row) {
SDataRow trow = malloc(dataRowLen(row)); SDataRow trow = taosMemoryMalloc(dataRowLen(row));
if (trow == NULL) return NULL; if (trow == NULL) return NULL;
dataRowCpy(trow, row); dataRowCpy(trow, row);
...@@ -244,7 +244,7 @@ SDataRow tdDataRowDup(SDataRow row) { ...@@ -244,7 +244,7 @@ SDataRow tdDataRowDup(SDataRow row) {
} }
SMemRow tdMemRowDup(SMemRow row) { SMemRow tdMemRowDup(SMemRow row) {
SMemRow trow = malloc(memRowTLen(row)); SMemRow trow = taosMemoryMalloc(memRowTLen(row));
if (trow == NULL) return NULL; if (trow == NULL) return NULL;
memRowCpy(trow, row); memRowCpy(trow, row);
...@@ -348,7 +348,7 @@ void *dataColSetOffset(SDataCol *pCol, int nEle) { ...@@ -348,7 +348,7 @@ void *dataColSetOffset(SDataCol *pCol, int nEle) {
} }
SDataCols *tdNewDataCols(int maxCols, int maxRows) { SDataCols *tdNewDataCols(int maxCols, int maxRows) {
SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols)); SDataCols *pCols = (SDataCols *)taosMemoryCalloc(1, sizeof(SDataCols));
if (pCols == NULL) { if (pCols == NULL) {
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno)); uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno));
return NULL; return NULL;
...@@ -360,7 +360,7 @@ SDataCols *tdNewDataCols(int maxCols, int maxRows) { ...@@ -360,7 +360,7 @@ SDataCols *tdNewDataCols(int maxCols, int maxRows) {
pCols->numOfCols = 0; pCols->numOfCols = 0;
if (maxCols > 0) { if (maxCols > 0) {
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol)); pCols->cols = (SDataCol *)taosMemoryCalloc(maxCols, sizeof(SDataCol));
if (pCols->cols == NULL) { if (pCols->cols == NULL) {
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols,
strerror(errno)); strerror(errno));
...@@ -384,7 +384,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) { ...@@ -384,7 +384,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
int oldMaxCols = pCols->maxCols; int oldMaxCols = pCols->maxCols;
if (schemaNCols(pSchema) > oldMaxCols) { if (schemaNCols(pSchema) > oldMaxCols) {
pCols->maxCols = schemaNCols(pSchema); pCols->maxCols = schemaNCols(pSchema);
void *ptr = (SDataCol *)realloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols); void *ptr = (SDataCol *)taosMemoryRealloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols);
if (ptr == NULL) return -1; if (ptr == NULL) return -1;
pCols->cols = ptr; pCols->cols = ptr;
for (i = oldMaxCols; i < pCols->maxCols; i++) { for (i = oldMaxCols; i < pCols->maxCols; i++) {
...@@ -411,12 +411,12 @@ SDataCols *tdFreeDataCols(SDataCols *pCols) { ...@@ -411,12 +411,12 @@ SDataCols *tdFreeDataCols(SDataCols *pCols) {
int maxCols = pCols->maxCols; int maxCols = pCols->maxCols;
for (i = 0; i < maxCols; i++) { for (i = 0; i < maxCols; i++) {
SDataCol *pCol = &pCols->cols[i]; SDataCol *pCol = &pCols->cols[i];
tfree(pCol->pData); taosMemoryFreeClear(pCol->pData);
} }
free(pCols->cols); taosMemoryFree(pCols->cols);
pCols->cols = NULL; pCols->cols = NULL;
} }
free(pCols); taosMemoryFree(pCols);
} }
return NULL; return NULL;
} }
...@@ -641,7 +641,7 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i ...@@ -641,7 +641,7 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
#endif #endif
SKVRow tdKVRowDup(SKVRow row) { SKVRow tdKVRowDup(SKVRow row) {
SKVRow trow = malloc(kvRowLen(row)); SKVRow trow = taosMemoryMalloc(kvRowLen(row));
if (trow == NULL) return NULL; if (trow == NULL) return NULL;
kvRowCpy(trow, row); kvRowCpy(trow, row);
...@@ -674,7 +674,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -674,7 +674,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
int oRowCols = kvRowNCols(row); int oRowCols = kvRowNCols(row);
ASSERT(diff > 0); ASSERT(diff > 0);
nrow = malloc(nRowLen); nrow = taosMemoryMalloc(nRowLen);
if (nrow == NULL) return -1; if (nrow == NULL) return -1;
kvRowSetLen(nrow, nRowLen); kvRowSetLen(nrow, nRowLen);
...@@ -692,7 +692,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -692,7 +692,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
tdSortKVRowByColIdx(nrow); tdSortKVRowByColIdx(nrow);
*orow = nrow; *orow = nrow;
free(row); taosMemoryFree(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)) {
...@@ -703,7 +703,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -703,7 +703,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
} else { // need to reallocate the memory } else { // need to reallocate the memory
int16_t nlen = kvRowLen(row) + (varDataTLen(value) - varDataTLen(pOldVal)); int16_t nlen = kvRowLen(row) + (varDataTLen(value) - varDataTLen(pOldVal));
ASSERT(nlen > 0); ASSERT(nlen > 0);
nrow = malloc(nlen); nrow = taosMemoryMalloc(nlen);
if (nrow == NULL) return -1; if (nrow == NULL) return -1;
kvRowSetLen(nrow, nlen); kvRowSetLen(nrow, nlen);
...@@ -728,7 +728,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) { ...@@ -728,7 +728,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
} }
*orow = nrow; *orow = nrow;
free(row); taosMemoryFree(row);
} }
} else { } else {
memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]); memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]);
...@@ -757,21 +757,21 @@ void *tdDecodeKVRow(void *buf, SKVRow *row) { ...@@ -757,21 +757,21 @@ void *tdDecodeKVRow(void *buf, SKVRow *row) {
int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) { int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
pBuilder->tCols = 128; pBuilder->tCols = 128;
pBuilder->nCols = 0; pBuilder->nCols = 0;
pBuilder->pColIdx = (SColIdx *)malloc(sizeof(SColIdx) * pBuilder->tCols); pBuilder->pColIdx = (SColIdx *)taosMemoryMalloc(sizeof(SColIdx) * pBuilder->tCols);
if (pBuilder->pColIdx == NULL) return -1; if (pBuilder->pColIdx == NULL) return -1;
pBuilder->alloc = 1024; pBuilder->alloc = 1024;
pBuilder->size = 0; pBuilder->size = 0;
pBuilder->buf = malloc(pBuilder->alloc); pBuilder->buf = taosMemoryMalloc(pBuilder->alloc);
if (pBuilder->buf == NULL) { if (pBuilder->buf == NULL) {
free(pBuilder->pColIdx); taosMemoryFree(pBuilder->pColIdx);
return -1; return -1;
} }
return 0; return 0;
} }
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) { void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
tfree(pBuilder->pColIdx); taosMemoryFreeClear(pBuilder->pColIdx);
tfree(pBuilder->buf); taosMemoryFreeClear(pBuilder->buf);
} }
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) { void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
...@@ -785,7 +785,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) { ...@@ -785,7 +785,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) {
tlen += TD_KV_ROW_HEAD_SIZE; tlen += TD_KV_ROW_HEAD_SIZE;
SKVRow row = malloc(tlen); SKVRow row = taosMemoryMalloc(tlen);
if (row == NULL) return NULL; if (row == NULL) return NULL;
kvRowSetNCols(row, pBuilder->nCols); kvRowSetNCols(row, pBuilder->nCols);
......
...@@ -371,7 +371,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -371,7 +371,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
case TD_SUPER_TABLE: case TD_SUPER_TABLE:
buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid)); buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid));
buf = taosDecodeFixedU32(buf, &(pReq->stbCfg.nCols)); buf = taosDecodeFixedU32(buf, &(pReq->stbCfg.nCols));
pReq->stbCfg.pSchema = (SSchema *)malloc(pReq->stbCfg.nCols * sizeof(SSchema)); pReq->stbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nCols * sizeof(SSchema));
for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) { for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) {
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type)); buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type));
buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].colId)); buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].colId));
...@@ -379,7 +379,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -379,7 +379,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name); buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name);
} }
buf = taosDecodeFixedU32(buf, &pReq->stbCfg.nTagCols); buf = taosDecodeFixedU32(buf, &pReq->stbCfg.nTagCols);
pReq->stbCfg.pTagSchema = (SSchema *)malloc(pReq->stbCfg.nTagCols * sizeof(SSchema)); pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) { for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) {
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type)); buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].colId); buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].colId);
...@@ -388,7 +388,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -388,7 +388,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
} }
buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols)); buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols));
if (pReq->stbCfg.nBSmaCols > 0) { if (pReq->stbCfg.nBSmaCols > 0) {
pReq->stbCfg.pBSmaCols = (col_id_t *)malloc(pReq->stbCfg.nBSmaCols * sizeof(col_id_t)); pReq->stbCfg.pBSmaCols = (col_id_t *)taosMemoryMalloc(pReq->stbCfg.nBSmaCols * sizeof(col_id_t));
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) { for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
buf = taosDecodeFixedI16(buf, pReq->stbCfg.pBSmaCols + i); buf = taosDecodeFixedI16(buf, pReq->stbCfg.pBSmaCols + i);
} }
...@@ -396,7 +396,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -396,7 +396,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq->stbCfg.pBSmaCols = NULL; pReq->stbCfg.pBSmaCols = NULL;
} }
if (pReq->rollup) { if (pReq->rollup) {
pReq->stbCfg.pRSmaParam = (SRSmaParam *)malloc(sizeof(SRSmaParam)); pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
SRSmaParam *param = pReq->stbCfg.pRSmaParam; SRSmaParam *param = pReq->stbCfg.pRSmaParam;
buf = taosDecodeFixedU32(buf, (uint32_t *)&param->xFilesFactor); buf = taosDecodeFixedU32(buf, (uint32_t *)&param->xFilesFactor);
buf = taosDecodeFixedI8(buf, &param->delayUnit); buf = taosDecodeFixedI8(buf, &param->delayUnit);
...@@ -419,7 +419,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -419,7 +419,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
break; break;
case TD_NORMAL_TABLE: case TD_NORMAL_TABLE:
buf = taosDecodeFixedU32(buf, &pReq->ntbCfg.nCols); buf = taosDecodeFixedU32(buf, &pReq->ntbCfg.nCols);
pReq->ntbCfg.pSchema = (SSchema *)malloc(pReq->ntbCfg.nCols * sizeof(SSchema)); pReq->ntbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->ntbCfg.nCols * sizeof(SSchema));
for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) { for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) {
buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type); buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type);
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].colId); buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].colId);
...@@ -428,7 +428,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -428,7 +428,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
} }
buf = taosDecodeFixedI16(buf, &(pReq->ntbCfg.nBSmaCols)); buf = taosDecodeFixedI16(buf, &(pReq->ntbCfg.nBSmaCols));
if (pReq->ntbCfg.nBSmaCols > 0) { if (pReq->ntbCfg.nBSmaCols > 0) {
pReq->ntbCfg.pBSmaCols = (col_id_t *)malloc(pReq->ntbCfg.nBSmaCols * sizeof(col_id_t)); pReq->ntbCfg.pBSmaCols = (col_id_t *)taosMemoryMalloc(pReq->ntbCfg.nBSmaCols * sizeof(col_id_t));
for (col_id_t i = 0; i < pReq->ntbCfg.nBSmaCols; ++i) { for (col_id_t i = 0; i < pReq->ntbCfg.nBSmaCols; ++i) {
buf = taosDecodeFixedI16(buf, pReq->ntbCfg.pBSmaCols + i); buf = taosDecodeFixedI16(buf, pReq->ntbCfg.pBSmaCols + i);
} }
...@@ -436,7 +436,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { ...@@ -436,7 +436,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq->ntbCfg.pBSmaCols = NULL; pReq->ntbCfg.pBSmaCols = NULL;
} }
if (pReq->rollup) { if (pReq->rollup) {
pReq->ntbCfg.pRSmaParam = (SRSmaParam *)malloc(sizeof(SRSmaParam)); pReq->ntbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
SRSmaParam *param = pReq->ntbCfg.pRSmaParam; SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
buf = taosDecodeFixedU32(buf, (uint32_t *)&param->xFilesFactor); buf = taosDecodeFixedU32(buf, (uint32_t *)&param->xFilesFactor);
buf = taosDecodeFixedI8(buf, &param->delayUnit); buf = taosDecodeFixedI8(buf, &param->delayUnit);
...@@ -608,7 +608,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR ...@@ -608,7 +608,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
} }
if (pReq->commentLen > 0) { if (pReq->commentLen > 0) {
pReq->comment = malloc(pReq->commentLen); pReq->comment = taosMemoryMalloc(pReq->commentLen);
if (pReq->comment == NULL) return -1; if (pReq->comment == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1;
} }
...@@ -623,7 +623,7 @@ void tFreeSMCreateStbReq(SMCreateStbReq *pReq) { ...@@ -623,7 +623,7 @@ void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
taosArrayDestroy(pReq->pColumns); taosArrayDestroy(pReq->pColumns);
taosArrayDestroy(pReq->pTags); taosArrayDestroy(pReq->pTags);
taosArrayDestroy(pReq->pSmas); taosArrayDestroy(pReq->pSmas);
tfree(pReq->comment); taosMemoryFreeClear(pReq->comment);
pReq->pColumns = NULL; pReq->pColumns = NULL;
pReq->pTags = NULL; pReq->pTags = NULL;
pReq->pSmas = NULL; pReq->pSmas = NULL;
...@@ -770,22 +770,22 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR ...@@ -770,22 +770,22 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->astLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->astLen) < 0) return -1;
if (pReq->exprLen > 0) { if (pReq->exprLen > 0) {
pReq->expr = malloc(pReq->exprLen); pReq->expr = taosMemoryMalloc(pReq->exprLen);
if (pReq->expr == NULL) return -1; if (pReq->expr == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->expr) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->expr) < 0) return -1;
} }
if (pReq->tagsFilterLen > 0) { if (pReq->tagsFilterLen > 0) {
pReq->tagsFilter = malloc(pReq->tagsFilterLen); pReq->tagsFilter = taosMemoryMalloc(pReq->tagsFilterLen);
if (pReq->tagsFilter == NULL) return -1; if (pReq->tagsFilter == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->tagsFilter) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->tagsFilter) < 0) return -1;
} }
if (pReq->sqlLen > 0) { if (pReq->sqlLen > 0) {
pReq->sql = malloc(pReq->sqlLen); pReq->sql = taosMemoryMalloc(pReq->sqlLen);
if (pReq->sql == NULL) return -1; if (pReq->sql == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
} }
if (pReq->astLen > 0) { if (pReq->astLen > 0) {
pReq->ast = malloc(pReq->astLen); pReq->ast = taosMemoryMalloc(pReq->astLen);
if (pReq->ast == NULL) return -1; if (pReq->ast == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
} }
...@@ -796,10 +796,10 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR ...@@ -796,10 +796,10 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
} }
void tFreeSMCreateSmaReq(SMCreateSmaReq *pReq) { void tFreeSMCreateSmaReq(SMCreateSmaReq *pReq) {
tfree(pReq->expr); taosMemoryFreeClear(pReq->expr);
tfree(pReq->tagsFilter); taosMemoryFreeClear(pReq->tagsFilter);
tfree(pReq->sql); taosMemoryFreeClear(pReq->sql);
tfree(pReq->ast); taosMemoryFreeClear(pReq->ast);
} }
int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) { int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) {
...@@ -1987,7 +1987,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) { ...@@ -1987,7 +1987,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->payloadLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->payloadLen) < 0) return -1;
if (pReq->payloadLen > 0) { if (pReq->payloadLen > 0) {
pReq->payload = malloc(pReq->payloadLen); pReq->payload = taosMemoryMalloc(pReq->payloadLen);
if (pReq->payload == NULL) return -1; if (pReq->payload == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->payload) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->payload) < 0) return -1;
} }
...@@ -1997,7 +1997,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) { ...@@ -1997,7 +1997,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
return 0; return 0;
} }
void tFreeSShowReq(SShowReq *pReq) { tfree(pReq->payload); } void tFreeSShowReq(SShowReq *pReq) { taosMemoryFreeClear(pReq->payload); }
int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq *pReq) { int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq *pReq) {
SCoder encoder = {0}; SCoder encoder = {0};
...@@ -2071,7 +2071,7 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) { ...@@ -2071,7 +2071,7 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) {
if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1;
int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns; int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns;
pRsp->pSchemas = malloc(sizeof(SSchema) * totalCols); pRsp->pSchemas = taosMemoryMalloc(sizeof(SSchema) * totalCols);
if (pRsp->pSchemas == NULL) return -1; if (pRsp->pSchemas == NULL) return -1;
for (int32_t i = 0; i < totalCols; ++i) { for (int32_t i = 0; i < totalCols; ++i) {
...@@ -2152,7 +2152,7 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc ...@@ -2152,7 +2152,7 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc
return 0; return 0;
} }
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { tfree(pRsp->pSchemas); } void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp *pRsp) { void tFreeSTableMetaBatchRsp(STableMetaBatchRsp *pRsp) {
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray); int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
...@@ -2304,13 +2304,13 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR ...@@ -2304,13 +2304,13 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if (tDecodeI32(&decoder, &astLen) < 0) return -1; if (tDecodeI32(&decoder, &astLen) < 0) return -1;
if (sqlLen > 0) { if (sqlLen > 0) {
pReq->sql = calloc(1, sqlLen + 1); pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
if (pReq->sql == NULL) return -1; if (pReq->sql == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
} }
if (astLen > 0) { if (astLen > 0) {
pReq->ast = calloc(1, astLen + 1); pReq->ast = taosMemoryCalloc(1, astLen + 1);
if (pReq->ast == NULL) return -1; if (pReq->ast == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
} }
...@@ -2322,8 +2322,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR ...@@ -2322,8 +2322,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
} }
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) { void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
tfree(pReq->sql); taosMemoryFreeClear(pReq->sql);
tfree(pReq->ast); taosMemoryFreeClear(pReq->ast);
} }
int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) { int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) {
...@@ -3074,13 +3074,13 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea ...@@ -3074,13 +3074,13 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
if (tDecodeI32(&decoder, &astLen) < 0) return -1; if (tDecodeI32(&decoder, &astLen) < 0) return -1;
if (sqlLen > 0) { if (sqlLen > 0) {
pReq->sql = calloc(1, sqlLen + 1); pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
if (pReq->sql == NULL) return -1; if (pReq->sql == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
} }
if (astLen > 0) { if (astLen > 0) {
pReq->ast = calloc(1, astLen + 1); pReq->ast = taosMemoryCalloc(1, astLen + 1);
if (pReq->ast == NULL) return -1; if (pReq->ast == NULL) return -1;
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
} }
...@@ -3091,6 +3091,6 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea ...@@ -3091,6 +3091,6 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
} }
void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
tfree(pReq->sql); taosMemoryFreeClear(pReq->sql);
tfree(pReq->ast); taosMemoryFreeClear(pReq->ast);
} }
...@@ -30,13 +30,13 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil ...@@ -30,13 +30,13 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil
return NULL; return NULL;
} }
SColumnFilterInfo* pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo)); SColumnFilterInfo* pFilter = taosMemoryCalloc(1, numOfFilters * sizeof(SColumnFilterInfo));
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters); memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
for (int32_t j = 0; j < numOfFilters; ++j) { for (int32_t j = 0; j < numOfFilters; ++j) {
if (pFilter[j].filterstr) { if (pFilter[j].filterstr) {
size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE; size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE;
pFilter[j].pz = (int64_t) calloc(1, len); pFilter[j].pz = (int64_t) taosMemoryCalloc(1, len);
memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len); memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len);
} }
...@@ -171,7 +171,7 @@ bool tNameIsValid(const SName* name) { ...@@ -171,7 +171,7 @@ bool tNameIsValid(const SName* name) {
SName* tNameDup(const SName* name) { SName* tNameDup(const SName* name) {
assert(name != NULL); assert(name != NULL);
SName* p = malloc(sizeof(SName)); SName* p = taosMemoryMalloc(sizeof(SName));
memcpy(p, name, sizeof(SName)); memcpy(p, name, sizeof(SName));
return p; return p;
} }
......
...@@ -119,7 +119,7 @@ int trbWriteCol(SRowBuilder *pRB, void *pData, col_id_t cid) { ...@@ -119,7 +119,7 @@ int trbWriteCol(SRowBuilder *pRB, void *pData, col_id_t cid) {
#endif #endif
STSRow *tdRowDup(STSRow *row) { STSRow *tdRowDup(STSRow *row) {
STSRow *trow = malloc(TD_ROW_LEN(row)); STSRow *trow = taosMemoryMalloc(TD_ROW_LEN(row));
if (trow == NULL) return NULL; if (trow == NULL) return NULL;
tdRowCpy(trow, row); tdRowCpy(trow, row);
......
...@@ -30,7 +30,7 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader); ...@@ -30,7 +30,7 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
* @return * @return
*/ */
STSBuf* tsBufCreate(bool autoDelete, int32_t order) { STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
STSBuf* pTSBuf = calloc(1, sizeof(STSBuf)); STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
if (pTSBuf == NULL) { if (pTSBuf == NULL) {
return NULL; return NULL;
} }
...@@ -41,7 +41,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) { ...@@ -41,7 +41,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+"); // pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
if (pTSBuf->pFile == NULL) { if (pTSBuf->pFile == NULL) {
free(pTSBuf); taosMemoryFree(pTSBuf);
return NULL; return NULL;
} }
...@@ -66,7 +66,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) { ...@@ -66,7 +66,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
} }
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
STSBuf* pTSBuf = calloc(1, sizeof(STSBuf)); STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
if (pTSBuf == NULL) { if (pTSBuf == NULL) {
return NULL; return NULL;
} }
...@@ -78,7 +78,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ...@@ -78,7 +78,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// pTSBuf->pFile = fopen(pTSBuf->path, "rb+"); // pTSBuf->pFile = fopen(pTSBuf->path, "rb+");
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_WRITE | TD_FILE_READ); pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_WRITE | TD_FILE_READ);
if (pTSBuf->pFile == NULL) { if (pTSBuf->pFile == NULL) {
free(pTSBuf); taosMemoryFree(pTSBuf);
return NULL; return NULL;
} }
...@@ -101,7 +101,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ...@@ -101,7 +101,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
if (header.numOfGroup > pTSBuf->numOfAlloc) { if (header.numOfGroup > pTSBuf->numOfAlloc) {
pTSBuf->numOfAlloc = header.numOfGroup; pTSBuf->numOfAlloc = header.numOfGroup;
STSGroupBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * pTSBuf->numOfAlloc); STSGroupBlockInfoEx* tmp = taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * pTSBuf->numOfAlloc);
if (tmp == NULL) { if (tmp == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
...@@ -122,7 +122,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ...@@ -122,7 +122,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
size_t infoSize = sizeof(STSGroupBlockInfo) * pTSBuf->numOfGroups; size_t infoSize = sizeof(STSGroupBlockInfo) * pTSBuf->numOfGroups;
STSGroupBlockInfo* buf = (STSGroupBlockInfo*)calloc(1, infoSize); STSGroupBlockInfo* buf = (STSGroupBlockInfo*)taosMemoryCalloc(1, infoSize);
if (buf == NULL) { if (buf == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
...@@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ...@@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
STSGroupBlockInfoEx* pBlockList = &pTSBuf->pData[i]; STSGroupBlockInfoEx* pBlockList = &pTSBuf->pData[i];
memcpy(&pBlockList->info, &buf[i], sizeof(STSGroupBlockInfo)); memcpy(&pBlockList->info, &buf[i], sizeof(STSGroupBlockInfo));
} }
free(buf); taosMemoryFree(buf);
ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_END); ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_END);
UNUSED(ret); UNUSED(ret);
...@@ -166,11 +166,11 @@ void* tsBufDestroy(STSBuf* pTSBuf) { ...@@ -166,11 +166,11 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
return NULL; return NULL;
} }
tfree(pTSBuf->assistBuf); taosMemoryFreeClear(pTSBuf->assistBuf);
tfree(pTSBuf->tsData.rawBuf); taosMemoryFreeClear(pTSBuf->tsData.rawBuf);
tfree(pTSBuf->pData); taosMemoryFreeClear(pTSBuf->pData);
tfree(pTSBuf->block.payload); taosMemoryFreeClear(pTSBuf->block.payload);
if (!pTSBuf->remainOpen) { if (!pTSBuf->remainOpen) {
taosCloseFile(&pTSBuf->pFile); taosCloseFile(&pTSBuf->pFile);
...@@ -184,7 +184,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) { ...@@ -184,7 +184,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
} }
taosVariantDestroy(&pTSBuf->block.tag); taosVariantDestroy(&pTSBuf->block.tag);
free(pTSBuf); taosMemoryFree(pTSBuf);
return NULL; return NULL;
} }
...@@ -200,7 +200,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) { ...@@ -200,7 +200,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5); uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5);
assert((int32_t)newSize > pTSBuf->numOfAlloc); assert((int32_t)newSize > pTSBuf->numOfAlloc);
STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)realloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
if (tmp == NULL) { if (tmp == NULL) {
return NULL; return NULL;
} }
...@@ -240,7 +240,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) { ...@@ -240,7 +240,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
static void shrinkBuffer(STSList* ptsData) { static void shrinkBuffer(STSList* ptsData) {
// shrink tmp buffer size if it consumes too many memory compared to the pre-defined size // shrink tmp buffer size if it consumes too many memory compared to the pre-defined size
if (ptsData->allocSize >= ptsData->threshold * 2) { if (ptsData->allocSize >= ptsData->threshold * 2) {
char* rawBuf = realloc(ptsData->rawBuf, MEM_BUF_SIZE); char* rawBuf = taosMemoryRealloc(ptsData->rawBuf, MEM_BUF_SIZE);
if (rawBuf) { if (rawBuf) {
ptsData->rawBuf = rawBuf; ptsData->rawBuf = rawBuf;
ptsData->allocSize = MEM_BUF_SIZE; ptsData->allocSize = MEM_BUF_SIZE;
...@@ -322,7 +322,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) { ...@@ -322,7 +322,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
static void expandBuffer(STSList* ptsData, int32_t inputSize) { static void expandBuffer(STSList* ptsData, int32_t inputSize) {
if (ptsData->allocSize - ptsData->len < inputSize) { if (ptsData->allocSize - ptsData->len < inputSize) {
int32_t newSize = inputSize + ptsData->len; int32_t newSize = inputSize + ptsData->len;
char* tmp = realloc(ptsData->rawBuf, (size_t)newSize); char* tmp = taosMemoryRealloc(ptsData->rawBuf, (size_t)newSize);
if (tmp == NULL) { if (tmp == NULL) {
// todo // todo
} }
...@@ -366,7 +366,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { ...@@ -366,7 +366,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
// NOTE: mix types tags are not supported // NOTE: mix types tags are not supported
size_t sz = 0; size_t sz = 0;
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) { if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
char* tp = realloc(pBlock->tag.pz, pBlock->tag.nLen + 1); char* tp = taosMemoryRealloc(pBlock->tag.pz, pBlock->tag.nLen + 1);
assert(tp != NULL); assert(tp != NULL);
memset(tp, 0, pBlock->tag.nLen + 1); memset(tp, 0, pBlock->tag.nLen + 1);
...@@ -812,7 +812,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { ...@@ -812,7 +812,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
if (pDestBuf->numOfAlloc < newSize) { if (pDestBuf->numOfAlloc < newSize) {
pDestBuf->numOfAlloc = newSize; pDestBuf->numOfAlloc = newSize;
STSGroupBlockInfoEx* tmp = realloc(pDestBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); STSGroupBlockInfoEx* tmp = taosMemoryRealloc(pDestBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
if (tmp == NULL) { if (tmp == NULL) {
return -1; return -1;
} }
...@@ -1028,13 +1028,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) { ...@@ -1028,13 +1028,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
const int32_t INITIAL_GROUPINFO_SIZE = 4; const int32_t INITIAL_GROUPINFO_SIZE = 4;
pTSBuf->numOfAlloc = INITIAL_GROUPINFO_SIZE; pTSBuf->numOfAlloc = INITIAL_GROUPINFO_SIZE;
pTSBuf->pData = calloc(pTSBuf->numOfAlloc, sizeof(STSGroupBlockInfoEx)); pTSBuf->pData = taosMemoryCalloc(pTSBuf->numOfAlloc, sizeof(STSGroupBlockInfoEx));
if (pTSBuf->pData == NULL) { if (pTSBuf->pData == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
} }
pTSBuf->tsData.rawBuf = malloc(MEM_BUF_SIZE); pTSBuf->tsData.rawBuf = taosMemoryMalloc(MEM_BUF_SIZE);
if (pTSBuf->tsData.rawBuf == NULL) { if (pTSBuf->tsData.rawBuf == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
...@@ -1044,13 +1044,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) { ...@@ -1044,13 +1044,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
pTSBuf->tsData.threshold = MEM_BUF_SIZE; pTSBuf->tsData.threshold = MEM_BUF_SIZE;
pTSBuf->tsData.allocSize = MEM_BUF_SIZE; pTSBuf->tsData.allocSize = MEM_BUF_SIZE;
pTSBuf->assistBuf = malloc(MEM_BUF_SIZE); pTSBuf->assistBuf = taosMemoryMalloc(MEM_BUF_SIZE);
if (pTSBuf->assistBuf == NULL) { if (pTSBuf->assistBuf == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
} }
pTSBuf->block.payload = malloc(MEM_BUF_SIZE); pTSBuf->block.payload = taosMemoryMalloc(MEM_BUF_SIZE);
if (pTSBuf->block.payload == NULL) { if (pTSBuf->block.payload == NULL) {
tsBufDestroy(pTSBuf); tsBufDestroy(pTSBuf);
return NULL; return NULL;
...@@ -1079,7 +1079,7 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id) { ...@@ -1079,7 +1079,7 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id) {
return; return;
} }
(*id) = malloc(tsBufGetNumOfGroup(pTSBuf) * sizeof(int32_t)); (*id) = taosMemoryMalloc(tsBufGetNumOfGroup(pTSBuf) * sizeof(int32_t));
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
(*id)[i] = pTSBuf->pData[i].info.id; (*id)[i] = pTSBuf->pData[i].info.id;
......
...@@ -199,14 +199,14 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin ...@@ -199,14 +199,14 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
size_t lenInwchar = len / TSDB_NCHAR_SIZE; size_t lenInwchar = len / TSDB_NCHAR_SIZE;
pVar->ucs4 = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE); memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
pVar->nLen = (int32_t)len; pVar->nLen = (int32_t)len;
break; break;
} }
case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method
pVar->pz = calloc(len + 1, sizeof(char)); pVar->pz = taosMemoryCalloc(len + 1, sizeof(char));
memcpy(pVar->pz, pz, len); memcpy(pVar->pz, pz, len);
pVar->nLen = (int32_t)len; pVar->nLen = (int32_t)len;
break; break;
...@@ -224,7 +224,7 @@ void taosVariantDestroy(SVariant *pVar) { ...@@ -224,7 +224,7 @@ void taosVariantDestroy(SVariant *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); taosMemoryFreeClear(pVar->pz);
pVar->nLen = 0; pVar->nLen = 0;
} }
...@@ -233,7 +233,7 @@ void taosVariantDestroy(SVariant *pVar) { ...@@ -233,7 +233,7 @@ void taosVariantDestroy(SVariant *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); taosMemoryFree(p);
} }
taosArrayDestroy(pVar->arr); taosArrayDestroy(pVar->arr);
pVar->arr = NULL; pVar->arr = NULL;
...@@ -254,7 +254,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { ...@@ -254,7 +254,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
pDst->nType = pSrc->nType; pDst->nType = pSrc->nType;
if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) { if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) {
int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE;
char *p = realloc(pDst->pz, len); char *p = taosMemoryRealloc(pDst->pz, len);
assert(p); assert(p);
memset(p, 0, len); memset(p, 0, len);
...@@ -402,18 +402,18 @@ static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -402,18 +402,18 @@ static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
// it is a in-place convert type for SVariant, local buffer is needed // it is a in-place convert type for SVariant, local buffer is needed
if (*pDest == pVariant->pz) { if (*pDest == pVariant->pz) {
pBuf = calloc(1, INITIAL_ALLOC_SIZE); pBuf = taosMemoryCalloc(1, INITIAL_ALLOC_SIZE);
} }
if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE; size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE;
if (pBuf != NULL) { if (pBuf != NULL) {
if (newSize >= INITIAL_ALLOC_SIZE) { if (newSize >= INITIAL_ALLOC_SIZE) {
pBuf = realloc(pBuf, newSize + 1); pBuf = taosMemoryRealloc(pBuf, newSize + 1);
} }
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf); taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf);
free(pVariant->ucs4); taosMemoryFree(pVariant->ucs4);
pBuf[newSize] = 0; pBuf[newSize] = 0;
} else { } else {
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest); taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest);
...@@ -460,23 +460,23 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -460,23 +460,23 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
} }
if (*pDest == pVariant->pz) { if (*pDest == pVariant->pz) {
TdUcs4 *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE); TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
if (!ret) { if (!ret) {
tfree(pWStr); taosMemoryFreeClear(pWStr);
return -1; return -1;
} }
// 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->ucs4); taosMemoryFree(pVariant->ucs4);
} }
pVariant->ucs4 = pWStr; pVariant->ucs4 = pWStr;
*pDestSize = taosUcs4len(pVariant->ucs4); *pDestSize = taosUcs4len(pVariant->ucs4);
// shrink the allocate memory, no need to check here. // shrink the allocate memory, no need to check here.
char *tmp = realloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE); char *tmp = taosMemoryRealloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE);
assert(tmp != NULL); assert(tmp != NULL);
pVariant->ucs4 = (TdUcs4 *)tmp; pVariant->ucs4 = (TdUcs4 *)tmp;
...@@ -526,7 +526,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result ...@@ -526,7 +526,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
if (token.type == TK_NULL) { if (token.type == TK_NULL) {
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -547,7 +547,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result ...@@ -547,7 +547,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
} }
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -566,7 +566,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result ...@@ -566,7 +566,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
if (token.type == TK_FLOAT) { if (token.type == TK_FLOAT) {
double v = wcstod(pVariant->ucs4, &endPtr); double v = wcstod(pVariant->ucs4, &endPtr);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -577,7 +577,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result ...@@ -577,7 +577,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *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); taosMemoryFree(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
setNull((char *)result, type, tDataTypes[type].bytes); setNull((char *)result, type, tDataTypes[type].bytes);
...@@ -585,7 +585,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result ...@@ -585,7 +585,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
} else { } else {
int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10); int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10);
if (releaseVariantPtr) { if (releaseVariantPtr) {
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->nLen = 0; pVariant->nLen = 0;
} }
...@@ -971,21 +971,21 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) { ...@@ -971,21 +971,21 @@ int32_t taosVariantTypeSetType(SVariant *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); taosMemoryFree(pVariant->pz);
return -1; return -1;
} }
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->d = v; pVariant->d = 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->ucs4, NULL); double v = wcstod(pVariant->ucs4, NULL);
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
free(pVariant->pz); taosMemoryFree(pVariant->pz);
return -1; return -1;
} }
free(pVariant->pz); taosMemoryFree(pVariant->pz);
pVariant->d = v; pVariant->d = 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) {
double tmp = (double)pVariant->i; double tmp = (double)pVariant->i;
......
...@@ -99,7 +99,7 @@ TEST(testCase, toInteger_test) { ...@@ -99,7 +99,7 @@ TEST(testCase, toInteger_test) {
} }
TEST(testCase, Datablock_test) { TEST(testCase, Datablock_test) {
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock))); SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
b->info.numOfCols = 2; b->info.numOfCols = 2;
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData)); b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
...@@ -108,8 +108,8 @@ TEST(testCase, Datablock_test) { ...@@ -108,8 +108,8 @@ TEST(testCase, Datablock_test) {
infoData.info.type = TSDB_DATA_TYPE_INT; infoData.info.type = TSDB_DATA_TYPE_INT;
infoData.info.colId = 1; infoData.info.colId = 1;
infoData.pData = (char*) calloc(40, infoData.info.bytes); infoData.pData = (char*) taosMemoryCalloc(40, infoData.info.bytes);
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (40/8)); infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (40/8));
taosArrayPush(b->pDataBlock, &infoData); taosArrayPush(b->pDataBlock, &infoData);
SColumnInfoData infoData1 = {0}; SColumnInfoData infoData1 = {0};
...@@ -117,7 +117,7 @@ TEST(testCase, Datablock_test) { ...@@ -117,7 +117,7 @@ TEST(testCase, Datablock_test) {
infoData1.info.type = TSDB_DATA_TYPE_BINARY; infoData1.info.type = TSDB_DATA_TYPE_BINARY;
infoData1.info.colId = 2; infoData1.info.colId = 2;
infoData1.varmeta.offset = (int32_t*) calloc(40, sizeof(uint32_t)); infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(40, sizeof(uint32_t));
taosArrayPush(b->pDataBlock, &infoData1); taosArrayPush(b->pDataBlock, &infoData1);
char* str = "the value of: %d"; char* str = "the value of: %d";
...@@ -178,7 +178,7 @@ TEST(testCase, Datablock_test) { ...@@ -178,7 +178,7 @@ TEST(testCase, Datablock_test) {
#if 0 #if 0
TEST(testCase, non_var_dataBlock_split_test) { TEST(testCase, non_var_dataBlock_split_test) {
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock))); SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
b->info.numOfCols = 2; b->info.numOfCols = 2;
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData)); b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
...@@ -189,8 +189,8 @@ TEST(testCase, non_var_dataBlock_split_test) { ...@@ -189,8 +189,8 @@ TEST(testCase, non_var_dataBlock_split_test) {
int32_t numOfRows = 1000000; int32_t numOfRows = 1000000;
infoData.pData = (char*) calloc(numOfRows, infoData.info.bytes); infoData.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8)); infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
taosArrayPush(b->pDataBlock, &infoData); taosArrayPush(b->pDataBlock, &infoData);
SColumnInfoData infoData1 = {0}; SColumnInfoData infoData1 = {0};
...@@ -198,8 +198,8 @@ TEST(testCase, non_var_dataBlock_split_test) { ...@@ -198,8 +198,8 @@ TEST(testCase, non_var_dataBlock_split_test) {
infoData1.info.type = TSDB_DATA_TYPE_TINYINT; infoData1.info.type = TSDB_DATA_TYPE_TINYINT;
infoData1.info.colId = 2; infoData1.info.colId = 2;
infoData1.pData = (char*) calloc(numOfRows, infoData.info.bytes); infoData1.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
infoData1.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8)); infoData1.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
taosArrayPush(b->pDataBlock, &infoData1); taosArrayPush(b->pDataBlock, &infoData1);
for(int32_t i = 0; i < numOfRows; ++i) { for(int32_t i = 0; i < numOfRows; ++i) {
...@@ -233,7 +233,7 @@ TEST(testCase, non_var_dataBlock_split_test) { ...@@ -233,7 +233,7 @@ TEST(testCase, non_var_dataBlock_split_test) {
#endif #endif
TEST(testCase, var_dataBlock_split_test) { TEST(testCase, var_dataBlock_split_test) {
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock))); SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
b->info.numOfCols = 2; b->info.numOfCols = 2;
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData)); b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
...@@ -244,8 +244,8 @@ TEST(testCase, var_dataBlock_split_test) { ...@@ -244,8 +244,8 @@ TEST(testCase, var_dataBlock_split_test) {
infoData.info.type = TSDB_DATA_TYPE_INT; infoData.info.type = TSDB_DATA_TYPE_INT;
infoData.info.colId = 1; infoData.info.colId = 1;
infoData.pData = (char*) calloc(numOfRows, infoData.info.bytes); infoData.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8)); infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
taosArrayPush(b->pDataBlock, &infoData); taosArrayPush(b->pDataBlock, &infoData);
SColumnInfoData infoData1 = {0}; SColumnInfoData infoData1 = {0};
...@@ -253,7 +253,7 @@ TEST(testCase, var_dataBlock_split_test) { ...@@ -253,7 +253,7 @@ TEST(testCase, var_dataBlock_split_test) {
infoData1.info.type = TSDB_DATA_TYPE_BINARY; infoData1.info.type = TSDB_DATA_TYPE_BINARY;
infoData1.info.colId = 2; infoData1.info.colId = 2;
infoData1.varmeta.offset = (int32_t*) calloc(numOfRows, sizeof(uint32_t)); infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(numOfRows, sizeof(uint32_t));
taosArrayPush(b->pDataBlock, &infoData1); taosArrayPush(b->pDataBlock, &infoData1);
char buf[41] = {0}; char buf[41] = {0};
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
#include "bndInt.h" #include "bndInt.h"
SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) { SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) {
SBnode *pBnode = calloc(1, sizeof(SBnode)); SBnode *pBnode = taosMemoryCalloc(1, sizeof(SBnode));
pBnode->msgCb = pOption->msgCb; pBnode->msgCb = pOption->msgCb;
return pBnode; return pBnode;
} }
void bndClose(SBnode *pBnode) { free(pBnode); } void bndClose(SBnode *pBnode) { taosMemoryFree(pBnode); }
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; } int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
......
...@@ -73,7 +73,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) { ...@@ -73,7 +73,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) {
bmCloseImp(pMgmt); bmCloseImp(pMgmt);
taosRemoveDir(pMgmt->path); taosRemoveDir(pMgmt->path);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("bnode-mgmt is dropped"); dInfo("bnode-mgmt is dropped");
return 0; return 0;
} }
...@@ -85,13 +85,13 @@ static void bmClose(SMgmtWrapper *pWrapper) { ...@@ -85,13 +85,13 @@ static void bmClose(SMgmtWrapper *pWrapper) {
dInfo("bnode-mgmt start to cleanup"); dInfo("bnode-mgmt start to cleanup");
bmCloseImp(pMgmt); bmCloseImp(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("bnode-mgmt is cleaned up"); dInfo("bnode-mgmt is cleaned up");
} }
int32_t bmOpen(SMgmtWrapper *pWrapper) { int32_t bmOpen(SMgmtWrapper *pWrapper) {
dInfo("bnode-mgmt start to init"); dInfo("bnode-mgmt start to init");
SBnodeMgmt *pMgmt = calloc(1, sizeof(SBnodeMgmt)); SBnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SBnodeMgmt));
if (pMgmt == NULL) { if (pMgmt == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -139,7 +139,7 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRsp, int32_t ...@@ -139,7 +139,7 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRsp, int32_t
dTrace("msg:%p, get from parent queue", pRsp); dTrace("msg:%p, get from parent queue", pRsp);
pRsp->pCont = pCont; pRsp->pCont = pCont;
dndSendRpcRsp(pWrapper, pRsp); dndSendRpcRsp(pWrapper, pRsp);
free(pRsp); taosMemoryFree(pRsp);
} }
static int32_t dndRunInMultiProcess(SDnode *pDnode) { static int32_t dndRunInMultiProcess(SDnode *pDnode) {
...@@ -174,8 +174,8 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) { ...@@ -174,8 +174,8 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont, .childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
.parentQueueSize = 1024 * 1024 * 2, // size will be a configuration item .parentQueueSize = 1024 * 1024 * 2, // size will be a configuration item
.parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue, .parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue,
.parentdMallocHeadFp = (ProcMallocFp)malloc, .parentdMallocHeadFp = (ProcMallocFp)taosMemoryMalloc,
.parentFreeHeadFp = (ProcFreeFp)free, .parentFreeHeadFp = (ProcFreeFp)taosMemoryFree,
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont, .parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
.parentFreeBodyFp = (ProcFreeFp)rpcFreeCont, .parentFreeBodyFp = (ProcFreeFp)rpcFreeCont,
.testFlag = 0, .testFlag = 0,
......
...@@ -20,7 +20,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { ...@@ -20,7 +20,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR; int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 1024; int32_t maxLen = 1024;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
char file[PATH_MAX]; char file[PATH_MAX];
TdFilePtr pFile = NULL; TdFilePtr pFile = NULL;
...@@ -57,7 +57,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { ...@@ -57,7 +57,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed); dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
_OVER: _OVER:
if (content != NULL) free(content); if (content != NULL) taosMemoryFree(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile); if (pFile != NULL) taosCloseFile(&pFile);
...@@ -78,7 +78,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) { ...@@ -78,7 +78,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 1024; int32_t maxLen = 1024;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed); len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
...@@ -87,7 +87,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) { ...@@ -87,7 +87,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
taosWriteFile(pFile, content, len); taosWriteFile(pFile, content, len);
taosFsyncFile(pFile); taosFsyncFile(pFile);
taosCloseFile(&pFile); taosCloseFile(&pFile);
free(content); taosMemoryFree(content);
char realfile[PATH_MAX]; char realfile[PATH_MAX];
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name); snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
......
...@@ -39,19 +39,19 @@ static int32_t dndInitMemory(SDnode *pDnode, const SDnodeOpt *pOption) { ...@@ -39,19 +39,19 @@ static int32_t dndInitMemory(SDnode *pDnode, const SDnodeOpt *pOption) {
static void dndClearMemory(SDnode *pDnode) { static void dndClearMemory(SDnode *pDnode) {
for (ENodeType n = 0; n < NODE_MAX; ++n) { for (ENodeType n = 0; n < NODE_MAX; ++n) {
SMgmtWrapper *pMgmt = &pDnode->wrappers[n]; SMgmtWrapper *pMgmt = &pDnode->wrappers[n];
tfree(pMgmt->path); taosMemoryFreeClear(pMgmt->path);
} }
if (pDnode->pLockFile != NULL) { if (pDnode->pLockFile != NULL) {
taosUnLockFile(pDnode->pLockFile); taosUnLockFile(pDnode->pLockFile);
taosCloseFile(&pDnode->pLockFile); taosCloseFile(&pDnode->pLockFile);
pDnode->pLockFile = NULL; pDnode->pLockFile = NULL;
} }
tfree(pDnode->localEp); taosMemoryFreeClear(pDnode->localEp);
tfree(pDnode->localFqdn); taosMemoryFreeClear(pDnode->localFqdn);
tfree(pDnode->firstEp); taosMemoryFreeClear(pDnode->firstEp);
tfree(pDnode->secondEp); taosMemoryFreeClear(pDnode->secondEp);
tfree(pDnode->dataDir); taosMemoryFreeClear(pDnode->dataDir);
free(pDnode); taosMemoryFree(pDnode);
dDebug("dnode object memory is cleared, data:%p", pDnode); dDebug("dnode object memory is cleared, data:%p", pDnode);
} }
...@@ -61,7 +61,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) { ...@@ -61,7 +61,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
char path[PATH_MAX] = {0}; char path[PATH_MAX] = {0};
SDnode *pDnode = NULL; SDnode *pDnode = NULL;
pDnode = calloc(1, sizeof(SDnode)); pDnode = taosMemoryCalloc(1, sizeof(SDnode));
if (pDnode == NULL) { if (pDnode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _OVER; goto _OVER;
......
...@@ -24,7 +24,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) { ...@@ -24,7 +24,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) {
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR; int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 256 * 1024; int32_t maxLen = 256 * 1024;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
char file[PATH_MAX]; char file[PATH_MAX];
TdFilePtr pFile = NULL; TdFilePtr pFile = NULL;
...@@ -134,7 +134,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) { ...@@ -134,7 +134,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) {
dmPrintDnodes(pMgmt); dmPrintDnodes(pMgmt);
PRASE_DNODE_OVER: PRASE_DNODE_OVER:
if (content != NULL) free(content); if (content != NULL) taosMemoryFree(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile); if (pFile != NULL) taosCloseFile(&pFile);
...@@ -171,7 +171,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) { ...@@ -171,7 +171,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 256 * 1024; int32_t maxLen = 256 * 1024;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pDnode->dnodeId); len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pDnode->dnodeId);
...@@ -197,7 +197,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) { ...@@ -197,7 +197,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
taosWriteFile(pFile, content, len); taosWriteFile(pFile, content, len);
taosFsyncFile(pFile); taosFsyncFile(pFile);
taosCloseFile(&pFile); taosCloseFile(&pFile);
free(content); taosMemoryFree(content);
char realfile[PATH_MAX]; char realfile[PATH_MAX];
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP); snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
......
...@@ -80,7 +80,7 @@ static int32_t dmStart(SMgmtWrapper *pWrapper) { ...@@ -80,7 +80,7 @@ static int32_t dmStart(SMgmtWrapper *pWrapper) {
int32_t dmInit(SMgmtWrapper *pWrapper) { int32_t dmInit(SMgmtWrapper *pWrapper) {
SDnode *pDnode = pWrapper->pDnode; SDnode *pDnode = pWrapper->pDnode;
SDnodeMgmt *pMgmt = calloc(1, sizeof(SDnodeMgmt)); SDnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SDnodeMgmt));
dInfo("dnode-mgmt start to init"); dInfo("dnode-mgmt start to init");
pDnode->dnodeId = 0; pDnode->dnodeId = 0;
...@@ -138,7 +138,7 @@ void dmCleanup(SMgmtWrapper *pWrapper) { ...@@ -138,7 +138,7 @@ void dmCleanup(SMgmtWrapper *pWrapper) {
taosWUnLockLatch(&pMgmt->latch); taosWUnLockLatch(&pMgmt->latch);
free(pMgmt); taosMemoryFree(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
dInfo("dnode-mgmt is cleaned up"); dInfo("dnode-mgmt is cleaned up");
} }
......
...@@ -20,7 +20,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) { ...@@ -20,7 +20,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR; int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 4096; int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
char file[PATH_MAX]; char file[PATH_MAX];
TdFilePtr pFile = NULL; TdFilePtr pFile = NULL;
...@@ -97,7 +97,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) { ...@@ -97,7 +97,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed); dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
PRASE_MNODE_OVER: PRASE_MNODE_OVER:
if (content != NULL) free(content); if (content != NULL) taosMemoryFree(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile); if (pFile != NULL) taosCloseFile(&pFile);
...@@ -118,7 +118,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) { ...@@ -118,7 +118,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 4096; int32_t maxLen = 4096;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", deployed); len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", deployed);
...@@ -139,7 +139,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) { ...@@ -139,7 +139,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
taosWriteFile(pFile, content, len); taosWriteFile(pFile, content, len);
taosFsyncFile(pFile); taosFsyncFile(pFile);
taosCloseFile(&pFile); taosCloseFile(&pFile);
free(content); taosMemoryFree(content);
char realfile[PATH_MAX]; char realfile[PATH_MAX];
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP); snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
......
...@@ -177,7 +177,7 @@ int32_t mmDrop(SMgmtWrapper *pWrapper) { ...@@ -177,7 +177,7 @@ int32_t mmDrop(SMgmtWrapper *pWrapper) {
mmCloseImp(pMgmt); mmCloseImp(pMgmt);
taosRemoveDir(pMgmt->path); taosRemoveDir(pMgmt->path);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("mnode-mgmt is dropped"); dInfo("mnode-mgmt is dropped");
return 0; return 0;
} }
...@@ -189,7 +189,7 @@ static void mmClose(SMgmtWrapper *pWrapper) { ...@@ -189,7 +189,7 @@ static void mmClose(SMgmtWrapper *pWrapper) {
dInfo("mnode-mgmt start to cleanup"); dInfo("mnode-mgmt start to cleanup");
mmCloseImp(pMgmt); mmCloseImp(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("mnode-mgmt is cleaned up"); dInfo("mnode-mgmt is cleaned up");
} }
...@@ -200,7 +200,7 @@ int32_t mmOpenFromMsg(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq) { ...@@ -200,7 +200,7 @@ int32_t mmOpenFromMsg(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq) {
return -1; return -1;
} }
SMnodeMgmt *pMgmt = calloc(1, sizeof(SMnodeMgmt)); SMnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SMnodeMgmt));
if (pMgmt == NULL) { if (pMgmt == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -76,7 +76,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) { ...@@ -76,7 +76,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) {
qmCloseImp(pMgmt); qmCloseImp(pMgmt);
taosRemoveDir(pMgmt->path); taosRemoveDir(pMgmt->path);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("qnode-mgmt is dropped"); dInfo("qnode-mgmt is dropped");
return 0; return 0;
} }
...@@ -88,13 +88,13 @@ static void qmClose(SMgmtWrapper *pWrapper) { ...@@ -88,13 +88,13 @@ static void qmClose(SMgmtWrapper *pWrapper) {
dInfo("qnode-mgmt start to cleanup"); dInfo("qnode-mgmt start to cleanup");
qmCloseImp(pMgmt); qmCloseImp(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("qnode-mgmt is cleaned up"); dInfo("qnode-mgmt is cleaned up");
} }
int32_t qmOpen(SMgmtWrapper *pWrapper) { int32_t qmOpen(SMgmtWrapper *pWrapper) {
dInfo("qnode-mgmt start to init"); dInfo("qnode-mgmt start to init");
SQnodeMgmt *pMgmt = calloc(1, sizeof(SQnodeMgmt)); SQnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SQnodeMgmt));
if (pMgmt == NULL) { if (pMgmt == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -73,7 +73,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) { ...@@ -73,7 +73,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) {
smCloseImp(pMgmt); smCloseImp(pMgmt);
taosRemoveDir(pMgmt->path); taosRemoveDir(pMgmt->path);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("snode-mgmt is dropped"); dInfo("snode-mgmt is dropped");
return 0; return 0;
} }
...@@ -85,13 +85,13 @@ static void smClose(SMgmtWrapper *pWrapper) { ...@@ -85,13 +85,13 @@ static void smClose(SMgmtWrapper *pWrapper) {
dInfo("snode-mgmt start to cleanup"); dInfo("snode-mgmt start to cleanup");
smCloseImp(pMgmt); smCloseImp(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
free(pMgmt); taosMemoryFree(pMgmt);
dInfo("snode-mgmt is cleaned up"); dInfo("snode-mgmt is cleaned up");
} }
int32_t smOpen(SMgmtWrapper *pWrapper) { int32_t smOpen(SMgmtWrapper *pWrapper) {
dInfo("snode-mgmt start to init"); dInfo("snode-mgmt start to init");
SSnodeMgmt *pMgmt = calloc(1, sizeof(SSnodeMgmt)); SSnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SSnodeMgmt));
if (pMgmt == NULL) { if (pMgmt == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -51,7 +51,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) { ...@@ -51,7 +51,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
} }
for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) { for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) {
SMultiWorker *pUniqueWorker = malloc(sizeof(SMultiWorker)); SMultiWorker *pUniqueWorker = taosMemoryMalloc(sizeof(SMultiWorker));
if (pUniqueWorker == NULL) { if (pUniqueWorker == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -98,7 +98,7 @@ class Testbase { ...@@ -98,7 +98,7 @@ class Testbase {
#define CheckBinaryByte(b, len) \ #define CheckBinaryByte(b, len) \
{ \ { \
char* bytes = (char*)calloc(1, len); \ char* bytes = (char*)taosMemoryCalloc(1, len); \
for (int32_t i = 0; i < len - 1; ++i) { \ for (int32_t i = 0; i < len - 1; ++i) { \
bytes[i] = b; \ bytes[i] = b; \
} \ } \
......
...@@ -25,9 +25,9 @@ static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) { ...@@ -25,9 +25,9 @@ static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) {
void TestClient::SetRpcRsp(SRpcMsg* rsp) { void TestClient::SetRpcRsp(SRpcMsg* rsp) {
if (this->pRsp) { if (this->pRsp) {
free(this->pRsp); taosMemoryFree(this->pRsp);
} }
this->pRsp = (SRpcMsg*)calloc(1, sizeof(SRpcMsg)); this->pRsp = (SRpcMsg*)taosMemoryCalloc(1, sizeof(SRpcMsg));
this->pRsp->msgType = rsp->msgType; this->pRsp->msgType = rsp->msgType;
this->pRsp->code = rsp->code; this->pRsp->code = rsp->code;
this->pRsp->pCont = rsp->pCont; this->pRsp->pCont = rsp->pCont;
......
...@@ -21,7 +21,7 @@ SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes) { ...@@ -21,7 +21,7 @@ SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes) {
int32_t num = 0; int32_t num = 0;
int32_t size = taosHashGetSize(pMgmt->hash); int32_t size = taosHashGetSize(pMgmt->hash);
SVnodeObj **pVnodes = calloc(size, sizeof(SVnodeObj *)); SVnodeObj **pVnodes = taosMemoryCalloc(size, sizeof(SVnodeObj *));
void *pIter = taosHashIterate(pMgmt->hash, NULL); void *pIter = taosHashIterate(pMgmt->hash, NULL);
while (pIter) { while (pIter) {
...@@ -48,7 +48,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n ...@@ -48,7 +48,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR; int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 30000; int32_t maxLen = 30000;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
cJSON *root = NULL; cJSON *root = NULL;
FILE *fp = NULL; FILE *fp = NULL;
char file[PATH_MAX]; char file[PATH_MAX];
...@@ -85,7 +85,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n ...@@ -85,7 +85,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
int32_t vnodesNum = cJSON_GetArraySize(vnodes); int32_t vnodesNum = cJSON_GetArraySize(vnodes);
if (vnodesNum > 0) { if (vnodesNum > 0) {
pCfgs = calloc(vnodesNum, sizeof(SWrapperCfg)); pCfgs = taosMemoryCalloc(vnodesNum, sizeof(SWrapperCfg));
if (pCfgs == NULL) { if (pCfgs == NULL) {
dError("failed to read %s since out of memory", file); dError("failed to read %s since out of memory", file);
goto PRASE_VNODE_OVER; goto PRASE_VNODE_OVER;
...@@ -140,7 +140,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n ...@@ -140,7 +140,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
dInfo("succcessed to read file %s", file); dInfo("succcessed to read file %s", file);
PRASE_VNODE_OVER: PRASE_VNODE_OVER:
if (content != NULL) free(content); if (content != NULL) taosMemoryFree(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile); if (pFile != NULL) taosCloseFile(&pFile);
...@@ -166,7 +166,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) { ...@@ -166,7 +166,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
int32_t len = 0; int32_t len = 0;
int32_t maxLen = 65536; int32_t maxLen = 65536;
char *content = calloc(1, maxLen + 1); char *content = taosMemoryCalloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, "{\n");
len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n"); len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n");
...@@ -190,7 +190,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) { ...@@ -190,7 +190,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
taosWriteFile(pFile, content, len); taosWriteFile(pFile, content, len);
taosFsyncFile(pFile); taosFsyncFile(pFile);
taosCloseFile(&pFile); taosCloseFile(&pFile);
free(content); taosMemoryFree(content);
terrno = 0; terrno = 0;
for (int32_t i = 0; i < numOfVnodes; ++i) { for (int32_t i = 0; i < numOfVnodes; ++i) {
...@@ -199,7 +199,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) { ...@@ -199,7 +199,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
} }
if (pVnodes != NULL) { if (pVnodes != NULL) {
free(pVnodes); taosMemoryFree(pVnodes);
} }
dDebug("successed to write %s", realfile); dDebug("successed to write %s", realfile);
......
...@@ -46,7 +46,7 @@ void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) { ...@@ -46,7 +46,7 @@ void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
} }
int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) { int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
SVnodeObj *pVnode = calloc(1, sizeof(SVnodeObj)); SVnodeObj *pVnode = taosMemoryCalloc(1, sizeof(SVnodeObj));
if (pVnode == NULL) { if (pVnode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -107,9 +107,9 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) { ...@@ -107,9 +107,9 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
vnodeDestroy(pVnode->path); vnodeDestroy(pVnode->path);
} }
free(pVnode->path); taosMemoryFree(pVnode->path);
free(pVnode->db); taosMemoryFree(pVnode->db);
free(pVnode); taosMemoryFree(pVnode);
} }
static void *vmOpenVnodeFunc(void *param) { static void *vmOpenVnodeFunc(void *param) {
...@@ -183,11 +183,11 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) { ...@@ -183,11 +183,11 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) {
#endif #endif
int32_t vnodesPerThread = numOfVnodes / threadNum + 1; int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
SVnodeThread *threads = calloc(threadNum, sizeof(SVnodeThread)); SVnodeThread *threads = taosMemoryCalloc(threadNum, sizeof(SVnodeThread));
for (int32_t t = 0; t < threadNum; ++t) { for (int32_t t = 0; t < threadNum; ++t) {
threads[t].threadIndex = t; threads[t].threadIndex = t;
threads[t].pMgmt = pMgmt; threads[t].pMgmt = pMgmt;
threads[t].pCfgs = calloc(vnodesPerThread, sizeof(SWrapperCfg)); threads[t].pCfgs = taosMemoryCalloc(vnodesPerThread, sizeof(SWrapperCfg));
} }
for (int32_t v = 0; v < numOfVnodes; ++v) { for (int32_t v = 0; v < numOfVnodes; ++v) {
...@@ -217,10 +217,10 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) { ...@@ -217,10 +217,10 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) {
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) { if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
taosThreadJoin(pThread->thread, NULL); taosThreadJoin(pThread->thread, NULL);
} }
free(pThread->pCfgs); taosMemoryFree(pThread->pCfgs);
} }
free(threads); taosMemoryFree(threads);
free(pCfgs); taosMemoryFree(pCfgs);
if (pMgmt->state.openVnodes != pMgmt->state.totalVnodes) { if (pMgmt->state.openVnodes != pMgmt->state.totalVnodes) {
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes); dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
...@@ -242,7 +242,7 @@ static void vmCloseVnodes(SVnodesMgmt *pMgmt) { ...@@ -242,7 +242,7 @@ static void vmCloseVnodes(SVnodesMgmt *pMgmt) {
} }
if (pVnodes != NULL) { if (pVnodes != NULL) {
free(pVnodes); taosMemoryFree(pVnodes);
} }
if (pMgmt->hash != NULL) { if (pMgmt->hash != NULL) {
...@@ -262,14 +262,14 @@ static void vmCleanup(SMgmtWrapper *pWrapper) { ...@@ -262,14 +262,14 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
vmStopWorker(pMgmt); vmStopWorker(pMgmt);
vnodeCleanup(); vnodeCleanup();
// walCleanUp(); // walCleanUp();
free(pMgmt); taosMemoryFree(pMgmt);
pWrapper->pMgmt = NULL; pWrapper->pMgmt = NULL;
dInfo("vnode-mgmt is cleaned up"); dInfo("vnode-mgmt is cleaned up");
} }
static int32_t vmInit(SMgmtWrapper *pWrapper) { static int32_t vmInit(SMgmtWrapper *pWrapper) {
SDnode *pDnode = pWrapper->pDnode; SDnode *pDnode = pWrapper->pDnode;
SVnodesMgmt *pMgmt = calloc(1, sizeof(SVnodesMgmt)); SVnodesMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SVnodesMgmt));
int32_t code = -1; int32_t code = -1;
dInfo("vnode-mgmt start to init"); dInfo("vnode-mgmt start to init");
......
...@@ -117,7 +117,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO ...@@ -117,7 +117,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
if (pRsp != NULL) { if (pRsp != NULL) {
pRsp->ahandle = pRpc->ahandle; pRsp->ahandle = pRpc->ahandle;
dndSendRsp(pVnode->pWrapper, pRsp); dndSendRsp(pVnode->pWrapper, pRsp);
free(pRsp); taosMemoryFree(pRsp);
} else { } else {
if (code != 0 && terrno != 0) code = terrno; if (code != 0 && terrno != 0) code = terrno;
vmSendRsp(pVnode->pWrapper, pMsg, code); vmSendRsp(pVnode->pWrapper, pMsg, code);
......
...@@ -442,7 +442,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerEp(void** buf, SMqConsumerEp* pConsu ...@@ -442,7 +442,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerEp(void** buf, SMqConsumerEp* pConsu
static FORCE_INLINE void tDeleteSMqConsumerEp(SMqConsumerEp* pConsumerEp) { static FORCE_INLINE void tDeleteSMqConsumerEp(SMqConsumerEp* pConsumerEp) {
if (pConsumerEp) { if (pConsumerEp) {
tfree(pConsumerEp->qmsg); taosMemoryFreeClear(pConsumerEp->qmsg);
} }
} }
...@@ -511,7 +511,7 @@ typedef struct { ...@@ -511,7 +511,7 @@ typedef struct {
} SMqSubscribeObj; } SMqSubscribeObj;
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() { static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
SMqSubscribeObj* pSub = calloc(1, sizeof(SMqSubscribeObj)); SMqSubscribeObj* pSub = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
if (pSub == NULL) { if (pSub == NULL) {
return NULL; return NULL;
} }
...@@ -538,10 +538,10 @@ static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() { ...@@ -538,10 +538,10 @@ static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
return pSub; return pSub;
_err: _err:
tfree(pSub->consumers); taosMemoryFreeClear(pSub->consumers);
tfree(pSub->lostConsumers); taosMemoryFreeClear(pSub->lostConsumers);
tfree(pSub->unassignedVg); taosMemoryFreeClear(pSub->unassignedVg);
tfree(pSub); taosMemoryFreeClear(pSub);
return NULL; return NULL;
} }
......
...@@ -158,7 +158,7 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) { ...@@ -158,7 +158,7 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) {
ACCT_DECODE_OVER: ACCT_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr()); mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -126,7 +126,7 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw) { ...@@ -126,7 +126,7 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw) {
BNODE_DECODE_OVER: BNODE_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("bnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); mError("bnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -191,7 +191,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -191,7 +191,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
createReq.dnodeId = pDnode->id; createReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -206,7 +206,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -206,7 +206,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -218,7 +218,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -218,7 +218,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -233,7 +233,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -233,7 +233,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) { if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -341,7 +341,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn ...@@ -341,7 +341,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -356,7 +356,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn ...@@ -356,7 +356,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
......
...@@ -116,7 +116,7 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) { ...@@ -116,7 +116,7 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
CLUSTER_DECODE_OVER: CLUSTER_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr()); mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -54,7 +54,7 @@ int32_t mndInitConsumer(SMnode *pMnode) { ...@@ -54,7 +54,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
void mndCleanupConsumer(SMnode *pMnode) {} void mndCleanupConsumer(SMnode *pMnode) {}
SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup) { SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup) {
SMqConsumerObj *pConsumer = calloc(1, sizeof(SMqConsumerObj)); SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
if (pConsumer == NULL) { if (pConsumer == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -79,7 +79,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { ...@@ -79,7 +79,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size); SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size);
if (pRaw == NULL) goto CM_ENCODE_OVER; if (pRaw == NULL) goto CM_ENCODE_OVER;
buf = malloc(tlen); buf = taosMemoryMalloc(tlen);
if (buf == NULL) goto CM_ENCODE_OVER; if (buf == NULL) goto CM_ENCODE_OVER;
void *abuf = buf; void *abuf = buf;
...@@ -94,7 +94,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { ...@@ -94,7 +94,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
CM_ENCODE_OVER: CM_ENCODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != 0) { if (terrno != 0) {
mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
...@@ -126,7 +126,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { ...@@ -126,7 +126,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
int32_t dataPos = 0; int32_t dataPos = 0;
int32_t len; int32_t len;
SDB_GET_INT32(pRaw, dataPos, &len, CM_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &len, CM_DECODE_OVER);
buf = malloc(len); buf = taosMemoryMalloc(len);
if (buf == NULL) goto CM_DECODE_OVER; if (buf == NULL) goto CM_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, buf, len, CM_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, buf, len, CM_DECODE_OVER);
SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE, CM_DECODE_OVER); SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE, CM_DECODE_OVER);
...@@ -138,10 +138,10 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { ...@@ -138,10 +138,10 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
CM_DECODE_OVER: CM_DECODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -193,7 +193,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { ...@@ -193,7 +193,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
DB_DECODE_OVER: DB_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr()); mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -370,7 +370,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -370,7 +370,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.msgType = TDMT_DND_CREATE_VNODE; action.msgType = TDMT_DND_CREATE_VNODE;
action.acceptableCode = TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
...@@ -401,7 +401,7 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -401,7 +401,7 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.msgType = TDMT_DND_DROP_VNODE; action.msgType = TDMT_DND_DROP_VNODE;
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) { if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
...@@ -483,7 +483,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate ...@@ -483,7 +483,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
code = 0; code = 0;
CREATE_DB_OVER: CREATE_DB_OVER:
free(pVgroups); taosMemoryFree(pVgroups);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return code; return code;
} }
...@@ -622,7 +622,7 @@ static int32_t mndBuildUpdateVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -622,7 +622,7 @@ static int32_t mndBuildUpdateVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_DND_ALTER_VNODE; action.msgType = TDMT_DND_ALTER_VNODE;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
...@@ -802,7 +802,7 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj * ...@@ -802,7 +802,7 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *
action.msgType = TDMT_DND_DROP_VNODE; action.msgType = TDMT_DND_DROP_VNODE;
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
...@@ -845,7 +845,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo ...@@ -845,7 +845,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
if (useRpcMalloc) { if (useRpcMalloc) {
pRsp = rpcMallocCont(rspLen); pRsp = rpcMallocCont(rspLen);
} else { } else {
pRsp = malloc(rspLen); pRsp = taosMemoryMalloc(rspLen);
} }
if (pRsp == NULL) { if (pRsp == NULL) {
...@@ -1156,7 +1156,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, ...@@ -1156,7 +1156,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
} }
int32_t rspLen = tSerializeSUseDbBatchRsp(NULL, 0, &batchUseRsp); int32_t rspLen = tSerializeSUseDbBatchRsp(NULL, 0, &batchUseRsp);
void *pRsp = malloc(rspLen); void *pRsp = taosMemoryMalloc(rspLen);
if (pRsp == NULL) { if (pRsp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeSUseDbBatchRsp(&batchUseRsp); tFreeSUseDbBatchRsp(&batchUseRsp);
......
...@@ -164,7 +164,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) { ...@@ -164,7 +164,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
DNODE_DECODE_OVER: DNODE_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("dnode:%d, failed to decode from raw:%p since %s", pDnode->id, pRaw, terrstr()); mError("dnode:%d, failed to decode from raw:%p since %s", pDnode->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -127,8 +127,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { ...@@ -127,8 +127,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, FUNC_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, FUNC_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, FUNC_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, FUNC_DECODE_OVER)
pFunc->pComment = calloc(1, pFunc->commentSize); pFunc->pComment = taosMemoryCalloc(1, pFunc->commentSize);
pFunc->pCode = calloc(1, pFunc->codeSize); pFunc->pCode = taosMemoryCalloc(1, pFunc->codeSize);
if (pFunc->pComment == NULL || pFunc->pCode == NULL) { if (pFunc->pComment == NULL || pFunc->pCode == NULL) {
goto FUNC_DECODE_OVER; goto FUNC_DECODE_OVER;
} }
...@@ -142,7 +142,7 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { ...@@ -142,7 +142,7 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
FUNC_DECODE_OVER: FUNC_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr()); mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -157,8 +157,8 @@ static int32_t mndFuncActionInsert(SSdb *pSdb, SFuncObj *pFunc) { ...@@ -157,8 +157,8 @@ static int32_t mndFuncActionInsert(SSdb *pSdb, SFuncObj *pFunc) {
static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) { static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
mTrace("func:%s, perform delete action, row:%p", pFunc->name, pFunc); mTrace("func:%s, perform delete action, row:%p", pFunc->name, pFunc);
tfree(pFunc->pCode); taosMemoryFreeClear(pFunc->pCode);
tfree(pFunc->pComment); taosMemoryFreeClear(pFunc->pComment);
return 0; return 0;
} }
...@@ -196,8 +196,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr ...@@ -196,8 +196,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
func.signature = pCreate->signature; func.signature = pCreate->signature;
func.commentSize = pCreate->commentSize; func.commentSize = pCreate->commentSize;
func.codeSize = pCreate->codeSize; func.codeSize = pCreate->codeSize;
func.pComment = malloc(func.commentSize); func.pComment = taosMemoryMalloc(func.commentSize);
func.pCode = malloc(func.codeSize); func.pCode = taosMemoryMalloc(func.codeSize);
if (func.pCode == NULL || func.pCode == NULL) { if (func.pCode == NULL || func.pCode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto CREATE_FUNC_OVER; goto CREATE_FUNC_OVER;
...@@ -228,8 +228,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr ...@@ -228,8 +228,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
code = 0; code = 0;
CREATE_FUNC_OVER: CREATE_FUNC_OVER:
free(func.pCode); taosMemoryFree(func.pCode);
free(func.pComment); taosMemoryFree(func.pComment);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return code; return code;
} }
......
...@@ -152,7 +152,7 @@ static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema ...@@ -152,7 +152,7 @@ static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema
//connection/application/ //connection/application/
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) { int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
SSchema *schema = calloc(colNum, sizeof(SSchema)); SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
if (NULL == schema) { if (NULL == schema) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -210,7 +210,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * ...@@ -210,7 +210,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
*pRsp = *meta; *pRsp = *meta;
pRsp->pSchemas = calloc(meta->numOfColumns, sizeof(SSchema)); pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
if (pRsp->pSchemas == NULL) { if (pRsp->pSchemas == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
pRsp->pSchemas = NULL; pRsp->pSchemas = NULL;
...@@ -241,7 +241,7 @@ void mndCleanupInfos(SMnode *pMnode) { ...@@ -241,7 +241,7 @@ void mndCleanupInfos(SMnode *pMnode) {
while (pIter) { while (pIter) {
STableMetaRsp *meta = (STableMetaRsp *)pIter; STableMetaRsp *meta = (STableMetaRsp *)pIter;
tfree(meta->pSchemas); taosMemoryFreeClear(meta->pSchemas);
pIter = taosHashIterate(pMnode->infosMeta, pIter); pIter = taosHashIterate(pMnode->infosMeta, pIter);
} }
......
...@@ -180,7 +180,7 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { ...@@ -180,7 +180,7 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) {
MNODE_DECODE_OVER: MNODE_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -313,7 +313,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno ...@@ -313,7 +313,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
createReq.dnodeId = pMObj->id; createReq.dnodeId = pMObj->id;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq); tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
action.epSet = mndGetDnodeEpset(pMObj->pDnode); action.epSet = mndGetDnodeEpset(pMObj->pDnode);
...@@ -323,7 +323,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno ...@@ -323,7 +323,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj); sdbRelease(pSdb, pMObj);
return -1; return -1;
...@@ -338,7 +338,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno ...@@ -338,7 +338,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
createReq.dnodeId = pObj->id; createReq.dnodeId = pObj->id;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq); tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
action.epSet = mndGetDnodeEpset(pDnode); action.epSet = mndGetDnodeEpset(pDnode);
...@@ -347,7 +347,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno ...@@ -347,7 +347,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
action.msgType = TDMT_DND_CREATE_MNODE; action.msgType = TDMT_DND_CREATE_MNODE;
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
...@@ -483,7 +483,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode ...@@ -483,7 +483,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
alterReq.dnodeId = pMObj->id; alterReq.dnodeId = pMObj->id;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq); tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq);
action.epSet = mndGetDnodeEpset(pMObj->pDnode); action.epSet = mndGetDnodeEpset(pMObj->pDnode);
...@@ -493,7 +493,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode ...@@ -493,7 +493,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pMObj); sdbRelease(pSdb, pMObj);
return -1; return -1;
...@@ -510,7 +510,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode ...@@ -510,7 +510,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
SDDropMnodeReq dropReq = {0}; SDDropMnodeReq dropReq = {0};
dropReq.dnodeId = pObj->id; dropReq.dnodeId = pObj->id;
int32_t contLen = tSerializeSMCreateDropMnodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropMnodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
tSerializeSMCreateDropMnodeReq(pReq, contLen, &dropReq); tSerializeSMCreateDropMnodeReq(pReq, contLen, &dropReq);
action.epSet = mndGetDnodeEpset(pDnode); action.epSet = mndGetDnodeEpset(pDnode);
...@@ -519,7 +519,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode ...@@ -519,7 +519,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
action.msgType = TDMT_DND_DROP_MNODE; action.msgType = TDMT_DND_DROP_MNODE;
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
} }
......
...@@ -59,7 +59,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) { ...@@ -59,7 +59,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) {
SSdbRaw *pRaw = sdbAllocRaw(SDB_OFFSET, MND_OFFSET_VER_NUMBER, size); SSdbRaw *pRaw = sdbAllocRaw(SDB_OFFSET, MND_OFFSET_VER_NUMBER, size);
if (pRaw == NULL) goto OFFSET_ENCODE_OVER; if (pRaw == NULL) goto OFFSET_ENCODE_OVER;
buf = malloc(tlen); buf = taosMemoryMalloc(tlen);
if (buf == NULL) goto OFFSET_ENCODE_OVER; if (buf == NULL) goto OFFSET_ENCODE_OVER;
void *abuf = buf; void *abuf = buf;
...@@ -74,7 +74,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) { ...@@ -74,7 +74,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
OFFSET_ENCODE_OVER: OFFSET_ENCODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("offset:%s, failed to encode to raw:%p since %s", pOffset->key, pRaw, terrstr()); mError("offset:%s, failed to encode to raw:%p since %s", pOffset->key, pRaw, terrstr());
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
...@@ -107,7 +107,7 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) { ...@@ -107,7 +107,7 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) {
int32_t dataPos = 0; int32_t dataPos = 0;
int32_t tlen; int32_t tlen;
SDB_GET_INT32(pRaw, dataPos, &tlen, OFFSET_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &tlen, OFFSET_DECODE_OVER);
buf = malloc(tlen + 1); buf = taosMemoryMalloc(tlen + 1);
if (buf == NULL) goto OFFSET_DECODE_OVER; if (buf == NULL) goto OFFSET_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_DECODE_OVER);
SDB_GET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_DECODE_OVER); SDB_GET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_DECODE_OVER);
...@@ -119,10 +119,10 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) { ...@@ -119,10 +119,10 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
OFFSET_DECODE_OVER: OFFSET_DECODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("offset:%s, failed to decode from raw:%p since %s", pOffset->key, pRaw, terrstr()); mError("offset:%s, failed to decode from raw:%p since %s", pOffset->key, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -130,7 +130,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid, ...@@ -130,7 +130,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
} }
static void mndFreeConn(SConnObj *pConn) { static void mndFreeConn(SConnObj *pConn) {
tfree(pConn->pQueries); taosMemoryFreeClear(pConn->pQueries);
mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn); mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn);
} }
...@@ -260,7 +260,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { ...@@ -260,7 +260,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
if (numOfQueries > 0) { if (numOfQueries > 0) {
if (pConn->pQueries == NULL) { if (pConn->pQueries == NULL) {
pConn->pQueries = calloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE); pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE);
} }
pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries); pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries);
...@@ -276,7 +276,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { ...@@ -276,7 +276,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
#if 0 #if 0
SClientHbRsp* pRsp = malloc(sizeof(SClientHbRsp)); SClientHbRsp* pRsp = taosMemoryMalloc(sizeof(SClientHbRsp));
if (pRsp == NULL) { if (pRsp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -292,7 +292,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { ...@@ -292,7 +292,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
SHashObj* pObj = pReq->info; SHashObj* pObj = pReq->info;
SKv* pKv = taosHashGet(pObj, "mq-tmp", strlen("mq-tmp") + 1); SKv* pKv = taosHashGet(pObj, "mq-tmp", strlen("mq-tmp") + 1);
if (pKv == NULL) { if (pKv == NULL) {
free(pRsp); taosMemoryFree(pRsp);
return NULL; return NULL;
} }
SMqHbMsg mqHb; SMqHbMsg mqHb;
...@@ -325,7 +325,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { ...@@ -325,7 +325,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
taosArrayPush(batchRsp.batchRsps, &innerBatchRsp); taosArrayPush(batchRsp.batchRsps, &innerBatchRsp);
} }
int32_t tlen = taosEncodeSMqHbBatchRsp(NULL, &batchRsp); int32_t tlen = taosEncodeSMqHbBatchRsp(NULL, &batchRsp);
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
//TODO //TODO
return NULL; return NULL;
...@@ -402,7 +402,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { ...@@ -402,7 +402,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
if (pRsp != NULL) { if (pRsp != NULL) {
taosArrayPush(batchRsp.rsps, pRsp); taosArrayPush(batchRsp.rsps, pRsp);
free(pRsp); taosMemoryFree(pRsp);
} }
} }
} }
...@@ -418,7 +418,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { ...@@ -418,7 +418,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
int32_t kvNum = (rsp->info) ? taosArrayGetSize(rsp->info) : 0; int32_t kvNum = (rsp->info) ? taosArrayGetSize(rsp->info) : 0;
for (int32_t n = 0; n < kvNum; ++n) { for (int32_t n = 0; n < kvNum; ++n) {
SKv *kv = taosArrayGet(rsp->info, n); SKv *kv = taosArrayGet(rsp->info, n);
tfree(kv->value); taosMemoryFreeClear(kv->value);
} }
taosArrayDestroy(rsp->info); taosArrayDestroy(rsp->info);
} }
......
...@@ -128,7 +128,7 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) { ...@@ -128,7 +128,7 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) {
QNODE_DECODE_OVER: QNODE_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("qnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); mError("qnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -193,7 +193,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -193,7 +193,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
createReq.dnodeId = pDnode->id; createReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -208,7 +208,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -208,7 +208,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -220,7 +220,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -220,7 +220,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -235,7 +235,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -235,7 +235,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) { if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -343,7 +343,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn ...@@ -343,7 +343,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -358,7 +358,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn ...@@ -358,7 +358,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -474,7 +474,7 @@ static int32_t mndProcessQnodeListReq(SNodeMsg *pReq) { ...@@ -474,7 +474,7 @@ static int32_t mndProcessQnodeListReq(SNodeMsg *pReq) {
} }
int32_t rspLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp); int32_t rspLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp);
void *pRsp = malloc(rspLen); void *pRsp = taosMemoryMalloc(rspLen);
if (pRsp == NULL) { if (pRsp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto QNODE_LIST_OVER; goto QNODE_LIST_OVER;
......
...@@ -41,7 +41,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet ...@@ -41,7 +41,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
int32_t size = encoder.pos; int32_t size = encoder.pos;
int32_t tlen = sizeof(SMsgHead) + size; int32_t tlen = sizeof(SMsgHead) + size;
tCoderClear(&encoder); tCoderClear(&encoder);
void* buf = malloc(tlen); void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -58,7 +58,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet ...@@ -58,7 +58,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
action.contLen = tlen; action.contLen = tlen;
action.msgType = type; action.msgType = type;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(buf); taosMemoryFree(buf);
return -1; return -1;
} }
return 0; return 0;
......
...@@ -146,7 +146,7 @@ static int32_t mndProcessShowReq(SNodeMsg *pReq) { ...@@ -146,7 +146,7 @@ static int32_t mndProcessShowReq(SNodeMsg *pReq) {
} }
showRsp.showId = pShow->id; showRsp.showId = pShow->id;
showRsp.tableMeta.pSchemas = calloc(TSDB_MAX_COLUMNS, sizeof(SSchema)); showRsp.tableMeta.pSchemas = taosMemoryCalloc(TSDB_MAX_COLUMNS, sizeof(SSchema));
if (showRsp.tableMeta.pSchemas == NULL) { if (showRsp.tableMeta.pSchemas == NULL) {
mndReleaseShowObj(pShow, true); mndReleaseShowObj(pShow, true);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -160,25 +160,25 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { ...@@ -160,25 +160,25 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pSma->astLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &pSma->astLen, _OVER)
if (pSma->exprLen > 0) { if (pSma->exprLen > 0) {
pSma->expr = calloc(pSma->exprLen, 1); pSma->expr = taosMemoryCalloc(pSma->exprLen, 1);
if (pSma->expr == NULL) goto _OVER; if (pSma->expr == NULL) goto _OVER;
SDB_GET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER)
} }
if (pSma->tagsFilterLen > 0) { if (pSma->tagsFilterLen > 0) {
pSma->tagsFilter = calloc(pSma->tagsFilterLen, 1); pSma->tagsFilter = taosMemoryCalloc(pSma->tagsFilterLen, 1);
if (pSma->tagsFilter == NULL) goto _OVER; if (pSma->tagsFilter == NULL) goto _OVER;
SDB_GET_BINARY(pRaw, dataPos, pSma->tagsFilter, pSma->tagsFilterLen, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->tagsFilter, pSma->tagsFilterLen, _OVER)
} }
if (pSma->sqlLen > 0) { if (pSma->sqlLen > 0) {
pSma->sql = calloc(pSma->sqlLen, 1); pSma->sql = taosMemoryCalloc(pSma->sqlLen, 1);
if (pSma->sql == NULL) goto _OVER; if (pSma->sql == NULL) goto _OVER;
SDB_GET_BINARY(pRaw, dataPos, pSma->sql, pSma->sqlLen, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->sql, pSma->sqlLen, _OVER)
} }
if (pSma->astLen > 0) { if (pSma->astLen > 0) {
pSma->ast = calloc(pSma->astLen, 1); pSma->ast = taosMemoryCalloc(pSma->astLen, 1);
if (pSma->ast == NULL) goto _OVER; if (pSma->ast == NULL) goto _OVER;
SDB_GET_BINARY(pRaw, dataPos, pSma->ast, pSma->astLen, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->ast, pSma->astLen, _OVER)
} }
...@@ -189,9 +189,9 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { ...@@ -189,9 +189,9 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) {
_OVER: _OVER:
if (terrno != 0) { if (terrno != 0) {
mError("sma:%s, failed to decode from raw:%p since %s", pSma->name, pRaw, terrstr()); mError("sma:%s, failed to decode from raw:%p since %s", pSma->name, pRaw, terrstr());
tfree(pSma->expr); taosMemoryFreeClear(pSma->expr);
tfree(pSma->tagsFilter); taosMemoryFreeClear(pSma->tagsFilter);
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -206,8 +206,8 @@ static int32_t mndSmaActionInsert(SSdb *pSdb, SSmaObj *pSma) { ...@@ -206,8 +206,8 @@ static int32_t mndSmaActionInsert(SSdb *pSdb, SSmaObj *pSma) {
static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSma) { static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSma) {
mTrace("sma:%s, perform delete action, row:%p", pSma->name, pSma); mTrace("sma:%s, perform delete action, row:%p", pSma->name, pSma);
tfree(pSma->tagsFilter); taosMemoryFreeClear(pSma->tagsFilter);
tfree(pSma->expr); taosMemoryFreeClear(pSma->expr);
return 0; return 0;
} }
...@@ -261,7 +261,7 @@ static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSm ...@@ -261,7 +261,7 @@ static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSm
req.tSma.tagsFilter = pSma->tagsFilter; req.tSma.tagsFilter = pSma->tagsFilter;
int32_t contLen = tSerializeSVCreateTSmaReq(NULL, &req) + sizeof(SMsgHead); int32_t contLen = tSerializeSVCreateTSmaReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead *pHead = malloc(contLen); SMsgHead *pHead = taosMemoryMalloc(contLen);
if (pHead == NULL) { if (pHead == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -287,7 +287,7 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma, ...@@ -287,7 +287,7 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma,
tstrncpy(req.indexName, (char *)tNameGetTableName(&name), TSDB_INDEX_NAME_LEN); tstrncpy(req.indexName, (char *)tNameGetTableName(&name), TSDB_INDEX_NAME_LEN);
int32_t contLen = tSerializeSVDropTSmaReq(NULL, &req) + sizeof(SMsgHead); int32_t contLen = tSerializeSVDropTSmaReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead *pHead = malloc(contLen); SMsgHead *pHead = taosMemoryMalloc(contLen);
if (pHead == NULL) { if (pHead == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -349,7 +349,7 @@ static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -349,7 +349,7 @@ static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_VND_CREATE_SMA; action.msgType = TDMT_VND_CREATE_SMA;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
...@@ -382,25 +382,25 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre ...@@ -382,25 +382,25 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
smaObj.astLen = pCreate->astLen; smaObj.astLen = pCreate->astLen;
if (smaObj.exprLen > 0) { if (smaObj.exprLen > 0) {
smaObj.expr = malloc(smaObj.exprLen); smaObj.expr = taosMemoryMalloc(smaObj.exprLen);
if (smaObj.expr == NULL) goto _OVER; if (smaObj.expr == NULL) goto _OVER;
memcpy(smaObj.expr, pCreate->expr, smaObj.exprLen); memcpy(smaObj.expr, pCreate->expr, smaObj.exprLen);
} }
if (smaObj.tagsFilterLen > 0) { if (smaObj.tagsFilterLen > 0) {
smaObj.tagsFilter = malloc(smaObj.tagsFilterLen); smaObj.tagsFilter = taosMemoryMalloc(smaObj.tagsFilterLen);
if (smaObj.tagsFilter == NULL) goto _OVER; if (smaObj.tagsFilter == NULL) goto _OVER;
memcpy(smaObj.tagsFilter, pCreate->tagsFilter, smaObj.tagsFilterLen); memcpy(smaObj.tagsFilter, pCreate->tagsFilter, smaObj.tagsFilterLen);
} }
if (smaObj.sqlLen > 0) { if (smaObj.sqlLen > 0) {
smaObj.sql = malloc(smaObj.sqlLen); smaObj.sql = taosMemoryMalloc(smaObj.sqlLen);
if (smaObj.sql == NULL) goto _OVER; if (smaObj.sql == NULL) goto _OVER;
memcpy(smaObj.sql, pCreate->sql, smaObj.sqlLen); memcpy(smaObj.sql, pCreate->sql, smaObj.sqlLen);
} }
if (smaObj.astLen > 0) { if (smaObj.astLen > 0) {
smaObj.ast = malloc(smaObj.astLen); smaObj.ast = taosMemoryMalloc(smaObj.astLen);
if (smaObj.ast == NULL) goto _OVER; if (smaObj.ast == NULL) goto _OVER;
memcpy(smaObj.ast, pCreate->ast, smaObj.astLen); memcpy(smaObj.ast, pCreate->ast, smaObj.astLen);
} }
...@@ -596,7 +596,7 @@ static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * ...@@ -596,7 +596,7 @@ static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
action.msgType = TDMT_VND_DROP_SMA; action.msgType = TDMT_VND_DROP_SMA;
action.acceptableCode = TSDB_CODE_VND_SMA_NOT_EXIST; action.acceptableCode = TSDB_CODE_VND_SMA_NOT_EXIST;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
......
...@@ -135,7 +135,7 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw) { ...@@ -135,7 +135,7 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw) {
SNODE_DECODE_OVER: SNODE_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("snode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); mError("snode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -200,7 +200,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -200,7 +200,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
createReq.dnodeId = pDnode->id; createReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -215,7 +215,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -215,7 +215,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -227,7 +227,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -227,7 +227,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -242,7 +242,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S ...@@ -242,7 +242,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendUndoAction(pTrans, &action) != 0) { if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
...@@ -352,7 +352,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn ...@@ -352,7 +352,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
dropReq.dnodeId = pDnode->id; dropReq.dnodeId = pDnode->id;
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -367,7 +367,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn ...@@ -367,7 +367,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
return -1; return -1;
} }
......
...@@ -175,9 +175,9 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { ...@@ -175,9 +175,9 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, STB_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, STB_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, STB_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, STB_DECODE_OVER)
pStb->pColumns = calloc(pStb->numOfColumns, sizeof(SSchema)); pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema));
pStb->pTags = calloc(pStb->numOfTags, sizeof(SSchema)); pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema));
pStb->pSmas = calloc(pStb->numOfSmas, sizeof(SSchema)); pStb->pSmas = taosMemoryCalloc(pStb->numOfSmas, sizeof(SSchema));
if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pSmas == NULL) { if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pSmas == NULL) {
goto STB_DECODE_OVER; goto STB_DECODE_OVER;
} }
...@@ -207,7 +207,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { ...@@ -207,7 +207,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
} }
if (pStb->commentLen > 0) { if (pStb->commentLen > 0) {
pStb->comment = calloc(pStb->commentLen, 1); pStb->comment = taosMemoryCalloc(pStb->commentLen, 1);
if (pStb->comment == NULL) goto STB_DECODE_OVER; if (pStb->comment == NULL) goto STB_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_DECODE_OVER) SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_DECODE_OVER)
} }
...@@ -218,10 +218,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { ...@@ -218,10 +218,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
STB_DECODE_OVER: STB_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("stb:%s, failed to decode from raw:%p since %s", pStb->name, pRaw, terrstr()); mError("stb:%s, failed to decode from raw:%p since %s", pStb->name, pRaw, terrstr());
tfree(pStb->pColumns); taosMemoryFreeClear(pStb->pColumns);
tfree(pStb->pTags); taosMemoryFreeClear(pStb->pTags);
tfree(pStb->comment); taosMemoryFreeClear(pStb->comment);
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -236,9 +236,9 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) { ...@@ -236,9 +236,9 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) {
static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) { static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
mTrace("stb:%s, perform delete action, row:%p", pStb->name, pStb); mTrace("stb:%s, perform delete action, row:%p", pStb->name, pStb);
tfree(pStb->pColumns); taosMemoryFreeClear(pStb->pColumns);
tfree(pStb->pTags); taosMemoryFreeClear(pStb->pTags);
tfree(pStb->comment); taosMemoryFreeClear(pStb->comment);
return 0; return 0;
} }
...@@ -248,9 +248,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { ...@@ -248,9 +248,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
taosWLockLatch(&pOld->lock); taosWLockLatch(&pOld->lock);
if (pOld->numOfColumns < pNew->numOfColumns) { if (pOld->numOfColumns < pNew->numOfColumns) {
void *pColumns = malloc(pNew->numOfColumns * sizeof(SSchema)); void *pColumns = taosMemoryMalloc(pNew->numOfColumns * sizeof(SSchema));
if (pColumns != NULL) { if (pColumns != NULL) {
free(pOld->pColumns); taosMemoryFree(pOld->pColumns);
pOld->pColumns = pColumns; pOld->pColumns = pColumns;
} else { } else {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -260,9 +260,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { ...@@ -260,9 +260,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
} }
if (pOld->numOfTags < pNew->numOfTags) { if (pOld->numOfTags < pNew->numOfTags) {
void *pTags = malloc(pNew->numOfTags * sizeof(SSchema)); void *pTags = taosMemoryMalloc(pNew->numOfTags * sizeof(SSchema));
if (pTags != NULL) { if (pTags != NULL) {
free(pOld->pTags); taosMemoryFree(pOld->pTags);
pOld->pTags = pTags; pOld->pTags = pTags;
} else { } else {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -272,9 +272,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { ...@@ -272,9 +272,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
} }
if (pOld->numOfSmas < pNew->numOfSmas) { if (pOld->numOfSmas < pNew->numOfSmas) {
void *pSmas = malloc(pNew->numOfSmas * sizeof(SSchema)); void *pSmas = taosMemoryMalloc(pNew->numOfSmas * sizeof(SSchema));
if (pSmas != NULL) { if (pSmas != NULL) {
free(pOld->pSmas); taosMemoryFree(pOld->pSmas);
pOld->pSmas = pSmas; pOld->pSmas = pSmas;
} else { } else {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -284,9 +284,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { ...@@ -284,9 +284,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
} }
if (pOld->commentLen < pNew->commentLen) { if (pOld->commentLen < pNew->commentLen) {
void *comment = malloc(pNew->commentLen); void *comment = taosMemoryMalloc(pNew->commentLen);
if (comment != NULL) { if (comment != NULL) {
free(pOld->comment); taosMemoryFree(pOld->comment);
pOld->comment = comment; pOld->comment = comment;
} else { } else {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -353,7 +353,7 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt ...@@ -353,7 +353,7 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
req.stbCfg.pTagSchema = pStb->pTags; req.stbCfg.pTagSchema = pStb->pTags;
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead); int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead *pHead = malloc(contLen); SMsgHead *pHead = taosMemoryMalloc(contLen);
if (pHead == NULL) { if (pHead == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -380,7 +380,7 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, ...@@ -380,7 +380,7 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
req.suid = pStb->uid; req.suid = pStb->uid;
int32_t contLen = tSerializeSVDropTbReq(NULL, &req) + sizeof(SMsgHead); int32_t contLen = tSerializeSVDropTbReq(NULL, &req) + sizeof(SMsgHead);
SMsgHead *pHead = malloc(contLen); SMsgHead *pHead = taosMemoryMalloc(contLen);
if (pHead == NULL) { if (pHead == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -508,7 +508,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -508,7 +508,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_VND_CREATE_STB; action.msgType = TDMT_VND_CREATE_STB;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
...@@ -547,7 +547,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -547,7 +547,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_VND_DROP_STB; action.msgType = TDMT_VND_DROP_STB;
if (mndTransAppendUndoAction(pTrans, &action) != 0) { if (mndTransAppendUndoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
...@@ -584,7 +584,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre ...@@ -584,7 +584,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj.numOfSmas = pCreate->numOfSmas; stbObj.numOfSmas = pCreate->numOfSmas;
stbObj.commentLen = pCreate->commentLen; stbObj.commentLen = pCreate->commentLen;
if (stbObj.commentLen > 0) { if (stbObj.commentLen > 0) {
stbObj.comment = calloc(stbObj.commentLen, 1); stbObj.comment = taosMemoryCalloc(stbObj.commentLen, 1);
if (stbObj.comment == NULL) { if (stbObj.comment == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -592,9 +592,9 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre ...@@ -592,9 +592,9 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
memcpy(stbObj.comment, pCreate->comment, stbObj.commentLen); memcpy(stbObj.comment, pCreate->comment, stbObj.commentLen);
} }
stbObj.pColumns = malloc(stbObj.numOfColumns * sizeof(SSchema)); stbObj.pColumns = taosMemoryMalloc(stbObj.numOfColumns * sizeof(SSchema));
stbObj.pTags = malloc(stbObj.numOfTags * sizeof(SSchema)); stbObj.pTags = taosMemoryMalloc(stbObj.numOfTags * sizeof(SSchema));
stbObj.pSmas = malloc(stbObj.numOfSmas * sizeof(SSchema)); stbObj.pSmas = taosMemoryMalloc(stbObj.numOfSmas * sizeof(SSchema));
if (stbObj.pColumns == NULL || stbObj.pTags == NULL || stbObj.pSmas == NULL) { if (stbObj.pColumns == NULL || stbObj.pTags == NULL || stbObj.pSmas == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -777,8 +777,8 @@ static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *col ...@@ -777,8 +777,8 @@ static int32_t mndFindSuperTableColumnIndex(const SStbObj *pStb, const char *col
} }
static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) { static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
pNew->pTags = calloc(pNew->numOfTags, sizeof(SSchema)); pNew->pTags = taosMemoryCalloc(pNew->numOfTags, sizeof(SSchema));
pNew->pColumns = calloc(pNew->numOfColumns, sizeof(SSchema)); pNew->pColumns = taosMemoryCalloc(pNew->numOfColumns, sizeof(SSchema));
if (pNew->pTags == NULL || pNew->pColumns == NULL) { if (pNew->pTags == NULL || pNew->pColumns == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -1071,7 +1071,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj ...@@ -1071,7 +1071,7 @@ static int32_t mndSetAlterStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action.contLen = contLen; action.contLen = contLen;
action.msgType = TDMT_VND_ALTER_STB; action.msgType = TDMT_VND_ALTER_STB;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
...@@ -1140,8 +1140,8 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAltertbReq *p ...@@ -1140,8 +1140,8 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAltertbReq *p
ALTER_STB_OVER: ALTER_STB_OVER:
mndTransDrop(pTrans); mndTransDrop(pTrans);
tfree(stbObj.pTags); taosMemoryFreeClear(stbObj.pTags);
tfree(stbObj.pColumns); taosMemoryFreeClear(stbObj.pColumns);
return code; return code;
} }
...@@ -1251,7 +1251,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * ...@@ -1251,7 +1251,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
action.msgType = TDMT_VND_DROP_STB; action.msgType = TDMT_VND_DROP_STB;
action.acceptableCode = TSDB_CODE_VND_TB_NOT_EXIST; action.acceptableCode = TSDB_CODE_VND_TB_NOT_EXIST;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(pReq); taosMemoryFree(pReq);
sdbCancelFetch(pSdb, pIter); sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
...@@ -1348,7 +1348,7 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa ...@@ -1348,7 +1348,7 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
taosRLockLatch(&pStb->lock); taosRLockLatch(&pStb->lock);
int32_t totalCols = pStb->numOfColumns + pStb->numOfTags; int32_t totalCols = pStb->numOfColumns + pStb->numOfTags;
pRsp->pSchemas = calloc(totalCols, sizeof(SSchema)); pRsp->pSchemas = taosMemoryCalloc(totalCols, sizeof(SSchema));
if (pRsp->pSchemas == NULL) { if (pRsp->pSchemas == NULL) {
taosRUnLockLatch(&pStb->lock); taosRUnLockLatch(&pStb->lock);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -1498,7 +1498,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int ...@@ -1498,7 +1498,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int
return -1; return -1;
} }
void *pRsp = malloc(rspLen); void *pRsp = taosMemoryMalloc(rspLen);
if (pRsp == NULL) { if (pRsp == NULL) {
tFreeSTableMetaBatchRsp(&batchMetaRsp); tFreeSTableMetaBatchRsp(&batchMetaRsp);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -84,7 +84,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) { ...@@ -84,7 +84,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
SSdbRaw *pRaw = sdbAllocRaw(SDB_STREAM, MND_STREAM_VER_NUMBER, size); SSdbRaw *pRaw = sdbAllocRaw(SDB_STREAM, MND_STREAM_VER_NUMBER, size);
if (pRaw == NULL) goto STREAM_ENCODE_OVER; if (pRaw == NULL) goto STREAM_ENCODE_OVER;
buf = malloc(tlen); buf = taosMemoryMalloc(tlen);
if (buf == NULL) goto STREAM_ENCODE_OVER; if (buf == NULL) goto STREAM_ENCODE_OVER;
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, tlen, TD_ENCODER); tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, tlen, TD_ENCODER);
...@@ -102,7 +102,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) { ...@@ -102,7 +102,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
STREAM_ENCODE_OVER: STREAM_ENCODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("stream:%s, failed to encode to raw:%p since %s", pStream->name, pRaw, terrstr()); mError("stream:%s, failed to encode to raw:%p since %s", pStream->name, pRaw, terrstr());
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
...@@ -135,7 +135,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { ...@@ -135,7 +135,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
int32_t tlen; int32_t tlen;
int32_t dataPos = 0; int32_t dataPos = 0;
SDB_GET_INT32(pRaw, dataPos, &tlen, STREAM_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &tlen, STREAM_DECODE_OVER);
buf = malloc(tlen + 1); buf = taosMemoryMalloc(tlen + 1);
if (buf == NULL) goto STREAM_DECODE_OVER; if (buf == NULL) goto STREAM_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, STREAM_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, buf, tlen, STREAM_DECODE_OVER);
...@@ -148,10 +148,10 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { ...@@ -148,10 +148,10 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
STREAM_DECODE_OVER: STREAM_DECODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("stream:%s, failed to decode from raw:%p since %s", pStream->name, pRaw, terrstr()); mError("stream:%s, failed to decode from raw:%p since %s", pStream->name, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -94,7 +94,7 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj ...@@ -94,7 +94,7 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj
if (mndSchedInitSubEp(pMnode, pTopic, pSub) < 0) { if (mndSchedInitSubEp(pMnode, pTopic, pSub) < 0) {
tDeleteSMqSubscribeObj(pSub); tDeleteSMqSubscribeObj(pSub);
free(pSub); taosMemoryFree(pSub);
return NULL; return NULL;
} }
...@@ -102,7 +102,7 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj ...@@ -102,7 +102,7 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj
if (mndInitUnassignedVg(pMnode, pTopic, pSub) < 0) { if (mndInitUnassignedVg(pMnode, pTopic, pSub) < 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
tDeleteSMqSubscribeObj(pSub); tDeleteSMqSubscribeObj(pSub);
free(pSub); taosMemoryFree(pSub);
return NULL; return NULL;
} }
#endif #endif
...@@ -118,7 +118,7 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume ...@@ -118,7 +118,7 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume
}; };
int32_t tlen = tEncodeSMqMVRebReq(NULL, &req); int32_t tlen = tEncodeSMqMVRebReq(NULL, &req);
void *buf = malloc(sizeof(SMsgHead) + tlen); void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -157,7 +157,7 @@ static int32_t mndPersistRebalanceMsg(SMnode *pMnode, STrans *pTrans, const SMqC ...@@ -157,7 +157,7 @@ static int32_t mndPersistRebalanceMsg(SMnode *pMnode, STrans *pTrans, const SMqC
mndReleaseVgroup(pMnode, pVgObj); mndReleaseVgroup(pMnode, pVgObj);
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(buf); taosMemoryFree(buf);
return -1; return -1;
} }
...@@ -169,7 +169,7 @@ static int32_t mndBuildCancelConnReq(void **pBuf, int32_t *pLen, const SMqConsum ...@@ -169,7 +169,7 @@ static int32_t mndBuildCancelConnReq(void **pBuf, int32_t *pLen, const SMqConsum
req.consumerId = pConsumerEp->consumerId; req.consumerId = pConsumerEp->consumerId;
int32_t tlen = tEncodeSMqSetCVgReq(NULL, &req); int32_t tlen = tEncodeSMqSetCVgReq(NULL, &req);
void *buf = malloc(sizeof(SMsgHead) + tlen); void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -203,7 +203,7 @@ static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMq ...@@ -203,7 +203,7 @@ static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMq
mndReleaseVgroup(pMnode, pVgObj); mndReleaseVgroup(pMnode, pVgObj);
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(buf); taosMemoryFree(buf);
return -1; return -1;
} }
...@@ -229,7 +229,7 @@ static int32_t mndProcessResetOffsetReq(SNodeMsg *pMsg) { ...@@ -229,7 +229,7 @@ static int32_t mndProcessResetOffsetReq(SNodeMsg *pMsg) {
SMqOffset *pOffset = &req.offsets[i]; SMqOffset *pOffset = &req.offsets[i];
SMqVgOffsets *pVgOffset = taosHashGet(pHash, &pOffset->vgId, sizeof(int32_t)); SMqVgOffsets *pVgOffset = taosHashGet(pHash, &pOffset->vgId, sizeof(int32_t));
if (pVgOffset == NULL) { if (pVgOffset == NULL) {
pVgOffset = malloc(sizeof(SMqVgOffsets)); pVgOffset = taosMemoryMalloc(sizeof(SMqVgOffsets));
if (pVgOffset == NULL) { if (pVgOffset == NULL) {
return -1; return -1;
} }
...@@ -407,7 +407,7 @@ static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) { ...@@ -407,7 +407,7 @@ static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) {
int32_t removeSz = taosArrayGetSize(pConsumer->recentRemovedTopics); int32_t removeSz = taosArrayGetSize(pConsumer->recentRemovedTopics);
for (int32_t i = 0; i < removeSz; i++) { for (int32_t i = 0; i < removeSz; i++) {
char *topicName = taosArrayGet(pConsumer->recentRemovedTopics, i); char *topicName = taosArrayGet(pConsumer->recentRemovedTopics, i);
free(topicName); taosMemoryFree(topicName);
} }
taosArrayClear(pConsumer->recentRemovedTopics); taosArrayClear(pConsumer->recentRemovedTopics);
} }
...@@ -441,7 +441,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) { ...@@ -441,7 +441,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
if (pIter == NULL) break; if (pIter == NULL) break;
SMqRebSubscribe *pRebSub = (SMqRebSubscribe *)pIter; SMqRebSubscribe *pRebSub = (SMqRebSubscribe *)pIter;
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebSub->key); SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebSub->key);
tfree(pRebSub->key); taosMemoryFreeClear(pRebSub->key);
mInfo("mq rebalance subscription: %s", pSub->key); mInfo("mq rebalance subscription: %s", pSub->key);
...@@ -762,8 +762,8 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) { ...@@ -762,8 +762,8 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
} }
mndReleaseTopic(pMnode, pTopic); mndReleaseTopic(pMnode, pTopic);
mndTransDrop(pTrans); mndTransDrop(pTrans);
tfree(topic); taosMemoryFreeClear(topic);
tfree(cgroup); taosMemoryFreeClear(cgroup);
} }
// rebalance condition2 : imbalance assignment // rebalance condition2 : imbalance assignment
} }
...@@ -836,7 +836,7 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT ...@@ -836,7 +836,7 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT
strcpy(req.cgroup, cgroup); strcpy(req.cgroup, cgroup);
strcpy(req.topicName, pTopic->name); strcpy(req.topicName, pTopic->name);
int32_t tlen = tEncodeSMqSetCVgReq(NULL, &req); int32_t tlen = tEncodeSMqSetCVgReq(NULL, &req);
void *buf = malloc(sizeof(SMsgHead) + tlen); void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -860,7 +860,7 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT ...@@ -860,7 +860,7 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT
mndReleaseVgroup(pMnode, pVgObj); mndReleaseVgroup(pMnode, pVgObj);
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {
free(buf); taosMemoryFree(buf);
return -1; return -1;
} }
return 0; return 0;
...@@ -877,7 +877,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) { ...@@ -877,7 +877,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) {
SSdbRaw *pRaw = sdbAllocRaw(SDB_SUBSCRIBE, MND_SUBSCRIBE_VER_NUMBER, size); SSdbRaw *pRaw = sdbAllocRaw(SDB_SUBSCRIBE, MND_SUBSCRIBE_VER_NUMBER, size);
if (pRaw == NULL) goto SUB_ENCODE_OVER; if (pRaw == NULL) goto SUB_ENCODE_OVER;
buf = malloc(tlen); buf = taosMemoryMalloc(tlen);
if (buf == NULL) goto SUB_ENCODE_OVER; if (buf == NULL) goto SUB_ENCODE_OVER;
void *abuf = buf; void *abuf = buf;
...@@ -892,7 +892,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) { ...@@ -892,7 +892,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
SUB_ENCODE_OVER: SUB_ENCODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("subscribe:%s, failed to encode to raw:%p since %s", pSub->key, pRaw, terrstr()); mError("subscribe:%s, failed to encode to raw:%p since %s", pSub->key, pRaw, terrstr());
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
...@@ -925,7 +925,7 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) { ...@@ -925,7 +925,7 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) {
int32_t dataPos = 0; int32_t dataPos = 0;
int32_t tlen; int32_t tlen;
SDB_GET_INT32(pRaw, dataPos, &tlen, SUB_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &tlen, SUB_DECODE_OVER);
buf = malloc(tlen + 1); buf = taosMemoryMalloc(tlen + 1);
if (buf == NULL) goto SUB_DECODE_OVER; if (buf == NULL) goto SUB_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, SUB_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, buf, tlen, SUB_DECODE_OVER);
SDB_GET_RESERVE(pRaw, dataPos, MND_SUBSCRIBE_RESERVE_SIZE, SUB_DECODE_OVER); SDB_GET_RESERVE(pRaw, dataPos, MND_SUBSCRIBE_RESERVE_SIZE, SUB_DECODE_OVER);
...@@ -937,10 +937,10 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) { ...@@ -937,10 +937,10 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) {
terrno = TSDB_CODE_SUCCESS; terrno = TSDB_CODE_SUCCESS;
SUB_DECODE_OVER: SUB_DECODE_OVER:
tfree(buf); taosMemoryFreeClear(buf);
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("subscribe:%s, failed to decode from raw:%p since %s", pSub->key, pRaw, terrstr()); mError("subscribe:%s, failed to decode from raw:%p since %s", pSub->key, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -1140,7 +1140,7 @@ static int32_t mndProcessSubscribeReq(SNodeMsg *pMsg) { ...@@ -1140,7 +1140,7 @@ static int32_t mndProcessSubscribeReq(SNodeMsg *pMsg) {
} }
} }
if (oldSub) taosArrayDestroyEx(oldSub, free); if (oldSub) taosArrayDestroyEx(oldSub, (void (*)(void*))taosMemoryFree);
// persist consumerObj // persist consumerObj
SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pConsumer); SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pConsumer);
......
...@@ -88,7 +88,7 @@ static int32_t mndProcessTelemTimer(SNodeMsg* pReq) { ...@@ -88,7 +88,7 @@ static int32_t mndProcessTelemTimer(SNodeMsg* pReq) {
char* pCont = mndBuildTelemetryReport(pMnode); char* pCont = mndBuildTelemetryReport(pMnode);
if (pCont != NULL) { if (pCont != NULL) {
taosSendHttpReport(TELEMETRY_SERVER, TELEMETRY_PORT, pCont, strlen(pCont), HTTP_FLAT); taosSendHttpReport(TELEMETRY_SERVER, TELEMETRY_PORT, pCont, strlen(pCont), HTTP_FLAT);
free(pCont); taosMemoryFree(pCont);
} }
taosWUnLockLatch(&pMgmt->lock); taosWUnLockLatch(&pMgmt->lock);
return 0; return 0;
......
...@@ -129,11 +129,11 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { ...@@ -129,11 +129,11 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER);
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
pTopic->sql = calloc(pTopic->sqlLen + 1, sizeof(char)); pTopic->sql = taosMemoryCalloc(pTopic->sqlLen + 1, sizeof(char));
SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER);
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
pTopic->logicalPlan = calloc(len + 1, sizeof(char)); pTopic->logicalPlan = taosMemoryCalloc(len + 1, sizeof(char));
if (pTopic->logicalPlan == NULL) { if (pTopic->logicalPlan == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto TOPIC_DECODE_OVER; goto TOPIC_DECODE_OVER;
...@@ -141,9 +141,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { ...@@ -141,9 +141,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER);
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
pTopic->physicalPlan = calloc(len + 1, sizeof(char)); pTopic->physicalPlan = taosMemoryCalloc(len + 1, sizeof(char));
if (pTopic->physicalPlan == NULL) { if (pTopic->physicalPlan == NULL) {
free(pTopic->logicalPlan); taosMemoryFree(pTopic->logicalPlan);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto TOPIC_DECODE_OVER; goto TOPIC_DECODE_OVER;
} }
...@@ -156,7 +156,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { ...@@ -156,7 +156,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
TOPIC_DECODE_OVER: TOPIC_DECODE_OVER:
if (terrno != TSDB_CODE_SUCCESS) { if (terrno != TSDB_CODE_SUCCESS) {
mError("topic:%s, failed to decode from raw:%p since %s", pTopic->name, pRaw, terrstr()); mError("topic:%s, failed to decode from raw:%p since %s", pTopic->name, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -214,7 +214,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) { ...@@ -214,7 +214,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
static SDDropTopicReq *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, SMqTopicObj *pTopic) { static SDDropTopicReq *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, SMqTopicObj *pTopic) {
int32_t contLen = sizeof(SDDropTopicReq); int32_t contLen = sizeof(SDDropTopicReq);
SDDropTopicReq *pDrop = calloc(1, contLen); SDDropTopicReq *pDrop = taosMemoryCalloc(1, contLen);
if (pDrop == NULL) { if (pDrop == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -286,7 +286,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq ...@@ -286,7 +286,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg);
if (pTrans == NULL) { if (pTrans == NULL) {
mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
tfree(pPlanStr); taosMemoryFreeClear(pPlanStr);
return -1; return -1;
} }
mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name); mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name);
...@@ -294,7 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq ...@@ -294,7 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj); SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
tfree(pPlanStr); taosMemoryFreeClear(pPlanStr);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
...@@ -302,12 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq ...@@ -302,12 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
tfree(pPlanStr); taosMemoryFreeClear(pPlanStr);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
tfree(pPlanStr); taosMemoryFreeClear(pPlanStr);
mndTransDrop(pTrans); mndTransDrop(pTrans);
return 0; return 0;
} }
......
...@@ -255,7 +255,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -255,7 +255,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
for (int32_t i = 0; i < redoLogNum; ++i) { for (int32_t i = 0; i < redoLogNum; ++i) {
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
pData = malloc(dataLen); pData = taosMemoryMalloc(dataLen);
if (pData == NULL) goto TRANS_DECODE_OVER; if (pData == NULL) goto TRANS_DECODE_OVER;
mTrace("raw:%p, is created", pData); mTrace("raw:%p, is created", pData);
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
...@@ -265,7 +265,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -265,7 +265,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
for (int32_t i = 0; i < undoLogNum; ++i) { for (int32_t i = 0; i < undoLogNum; ++i) {
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
pData = malloc(dataLen); pData = taosMemoryMalloc(dataLen);
if (pData == NULL) goto TRANS_DECODE_OVER; if (pData == NULL) goto TRANS_DECODE_OVER;
mTrace("raw:%p, is created", pData); mTrace("raw:%p, is created", pData);
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
...@@ -275,7 +275,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -275,7 +275,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
for (int32_t i = 0; i < commitLogNum; ++i) { for (int32_t i = 0; i < commitLogNum; ++i) {
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
pData = malloc(dataLen); pData = taosMemoryMalloc(dataLen);
if (pData == NULL) goto TRANS_DECODE_OVER; if (pData == NULL) goto TRANS_DECODE_OVER;
mTrace("raw:%p, is created", pData); mTrace("raw:%p, is created", pData);
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
...@@ -288,7 +288,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -288,7 +288,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER) SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER)
action.pCont = malloc(action.contLen); action.pCont = taosMemoryMalloc(action.contLen);
if (action.pCont == NULL) goto TRANS_DECODE_OVER; if (action.pCont == NULL) goto TRANS_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER);
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto TRANS_DECODE_OVER; if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto TRANS_DECODE_OVER;
...@@ -300,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -300,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER) SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER)
SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER)
action.pCont = malloc(action.contLen); action.pCont = taosMemoryMalloc(action.contLen);
if (action.pCont == NULL) goto TRANS_DECODE_OVER; if (action.pCont == NULL) goto TRANS_DECODE_OVER;
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER);
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto TRANS_DECODE_OVER; if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto TRANS_DECODE_OVER;
...@@ -315,9 +315,9 @@ TRANS_DECODE_OVER: ...@@ -315,9 +315,9 @@ TRANS_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr()); mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
mndTransDropData(pTrans); mndTransDropData(pTrans);
tfree(pRow); taosMemoryFreeClear(pRow);
tfree(pData); taosMemoryFreeClear(pData);
tfree(action.pCont); taosMemoryFreeClear(action.pCont);
return NULL; return NULL;
} }
...@@ -428,7 +428,7 @@ static void mndTransDropData(STrans *pTrans) { ...@@ -428,7 +428,7 @@ static void mndTransDropData(STrans *pTrans) {
mndTransDropActions(pTrans->redoActions); mndTransDropActions(pTrans->redoActions);
mndTransDropActions(pTrans->undoActions); mndTransDropActions(pTrans->undoActions);
if (pTrans->rpcRsp != NULL) { if (pTrans->rpcRsp != NULL) {
free(pTrans->rpcRsp); taosMemoryFree(pTrans->rpcRsp);
pTrans->rpcRsp = NULL; pTrans->rpcRsp = NULL;
pTrans->rpcRspLen = 0; pTrans->rpcRspLen = 0;
} }
...@@ -472,7 +472,7 @@ static void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) { ...@@ -472,7 +472,7 @@ static void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
} }
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const SRpcMsg *pReq) { STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const SRpcMsg *pReq) {
STrans *pTrans = calloc(1, sizeof(STrans)); STrans *pTrans = taosMemoryCalloc(1, sizeof(STrans));
if (pTrans == NULL) { if (pTrans == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed to create transaction since %s", terrstr()); mError("failed to create transaction since %s", terrstr());
...@@ -517,7 +517,7 @@ static void mndTransDropActions(SArray *pArray) { ...@@ -517,7 +517,7 @@ static void mndTransDropActions(SArray *pArray) {
int32_t size = taosArrayGetSize(pArray); int32_t size = taosArrayGetSize(pArray);
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
STransAction *pAction = taosArrayGet(pArray, i); STransAction *pAction = taosArrayGet(pArray, i);
tfree(pAction->pCont); taosMemoryFreeClear(pAction->pCont);
} }
taosArrayDestroy(pArray); taosArrayDestroy(pArray);
...@@ -527,7 +527,7 @@ void mndTransDrop(STrans *pTrans) { ...@@ -527,7 +527,7 @@ void mndTransDrop(STrans *pTrans) {
if (pTrans != NULL) { if (pTrans != NULL) {
mndTransDropData(pTrans); mndTransDropData(pTrans);
mDebug("trans:%d, is dropped, data:%p", pTrans->id, pTrans); mDebug("trans:%d, is dropped, data:%p", pTrans->id, pTrans);
tfree(pTrans); taosMemoryFreeClear(pTrans);
} }
} }
...@@ -762,7 +762,7 @@ static void mndTransSendRpcRsp(STrans *pTrans) { ...@@ -762,7 +762,7 @@ static void mndTransSendRpcRsp(STrans *pTrans) {
if (rpcCont != NULL) { if (rpcCont != NULL) {
memcpy(rpcCont, pTrans->rpcRsp, pTrans->rpcRspLen); memcpy(rpcCont, pTrans->rpcRsp, pTrans->rpcRspLen);
} }
free(pTrans->rpcRsp); taosMemoryFree(pTrans->rpcRsp);
mDebug("trans:%d, send rsp, code:0x%04x stage:%d app:%p", pTrans->id, pTrans->code & 0xFFFF, pTrans->stage, mDebug("trans:%d, send rsp, code:0x%04x stage:%d app:%p", pTrans->id, pTrans->code & 0xFFFF, pTrans->stage,
pTrans->rpcAHandle); pTrans->rpcAHandle);
......
...@@ -201,7 +201,7 @@ USER_DECODE_OVER: ...@@ -201,7 +201,7 @@ USER_DECODE_OVER:
mError("user:%s, failed to decode from raw:%p since %s", pUser->user, pRaw, terrstr()); mError("user:%s, failed to decode from raw:%p since %s", pUser->user, pRaw, terrstr());
taosHashCleanup(pUser->readDbs); taosHashCleanup(pUser->readDbs);
taosHashCleanup(pUser->writeDbs); taosHashCleanup(pUser->writeDbs);
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
......
...@@ -146,7 +146,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { ...@@ -146,7 +146,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
VG_DECODE_OVER: VG_DECODE_OVER:
if (terrno != 0) { if (terrno != 0) {
mError("vgId:%d, failed to decode from raw:%p since %s", pVgroup->vgId, pRaw, terrstr()); mError("vgId:%d, failed to decode from raw:%p since %s", pVgroup->vgId, pRaw, terrstr());
tfree(pRow); taosMemoryFreeClear(pRow);
return NULL; return NULL;
} }
...@@ -250,7 +250,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg ...@@ -250,7 +250,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
return NULL; return NULL;
} }
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -274,7 +274,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb ...@@ -274,7 +274,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb
return NULL; return NULL;
} }
void *pReq = malloc(contLen); void *pReq = taosMemoryMalloc(contLen);
if (pReq == NULL) { if (pReq == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -376,7 +376,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { ...@@ -376,7 +376,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
SArray *pArray = NULL; SArray *pArray = NULL;
SVgObj *pVgroups = NULL; SVgObj *pVgroups = NULL;
pVgroups = calloc(pDb->cfg.numOfVgroups, sizeof(SVgObj)); pVgroups = taosMemoryCalloc(pDb->cfg.numOfVgroups, sizeof(SVgObj));
if (pVgroups == NULL) { if (pVgroups == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto ALLOC_VGROUP_OVER; goto ALLOC_VGROUP_OVER;
...@@ -430,7 +430,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { ...@@ -430,7 +430,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
mDebug("db:%s, %d vgroups is alloced, replica:%d", pDb->name, pDb->cfg.numOfVgroups, pDb->cfg.replications); mDebug("db:%s, %d vgroups is alloced, replica:%d", pDb->name, pDb->cfg.numOfVgroups, pDb->cfg.replications);
ALLOC_VGROUP_OVER: ALLOC_VGROUP_OVER:
if (code != 0) free(pVgroups); if (code != 0) taosMemoryFree(pVgroups);
taosArrayDestroy(pArray); taosArrayDestroy(pArray);
return code; return code;
} }
......
...@@ -283,7 +283,7 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { ...@@ -283,7 +283,7 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
mDebug("start to open mnode in %s", path); mDebug("start to open mnode in %s", path);
SMnode *pMnode = calloc(1, sizeof(SMnode)); SMnode *pMnode = taosMemoryCalloc(1, sizeof(SMnode));
if (pMnode == NULL) { if (pMnode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed to open mnode since %s", terrstr()); mError("failed to open mnode since %s", terrstr());
...@@ -295,7 +295,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { ...@@ -295,7 +295,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
pMnode->pSteps = taosArrayInit(24, sizeof(SMnodeStep)); pMnode->pSteps = taosArrayInit(24, sizeof(SMnodeStep));
if (pMnode->pSteps == NULL) { if (pMnode->pSteps == NULL) {
free(pMnode); taosMemoryFree(pMnode);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed to open mnode since %s", terrstr()); mError("failed to open mnode since %s", terrstr());
return NULL; return NULL;
...@@ -346,8 +346,8 @@ void mndClose(SMnode *pMnode) { ...@@ -346,8 +346,8 @@ void mndClose(SMnode *pMnode) {
if (pMnode != NULL) { if (pMnode != NULL) {
mDebug("start to close mnode"); mDebug("start to close mnode");
mndCleanupSteps(pMnode, -1); mndCleanupSteps(pMnode, -1);
tfree(pMnode->path); taosMemoryFreeClear(pMnode->path);
tfree(pMnode); taosMemoryFreeClear(pMnode);
mDebug("mnode is closed"); mDebug("mnode is closed");
} }
} }
......
...@@ -29,7 +29,7 @@ class MndTestTrans : public ::testing::Test { ...@@ -29,7 +29,7 @@ class MndTestTrans : public ::testing::Test {
char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data";
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ); TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
int32_t size = 3 * 1024 * 1024; int32_t size = 3 * 1024 * 1024;
void* buffer = malloc(size); void* buffer = taosMemoryMalloc(size);
int32_t readLen = taosReadFile(pFile, buffer, size); int32_t readLen = taosReadFile(pFile, buffer, size);
if (readLen < 0 || readLen == size) { if (readLen < 0 || readLen == size) {
ASSERT(1); ASSERT(1);
...@@ -43,7 +43,7 @@ class MndTestTrans : public ::testing::Test { ...@@ -43,7 +43,7 @@ class MndTestTrans : public ::testing::Test {
if (writeLen < 0 || writeLen == readLen) { if (writeLen < 0 || writeLen == readLen) {
ASSERT(1); ASSERT(1);
} }
free(buffer); taosMemoryFree(buffer);
taosFsyncFile(pFile); taosFsyncFile(pFile);
taosCloseFile(&pFile); taosCloseFile(&pFile);
taosMsleep(1000); taosMsleep(1000);
......
...@@ -21,7 +21,7 @@ static int32_t sdbCreateDir(SSdb *pSdb); ...@@ -21,7 +21,7 @@ static int32_t sdbCreateDir(SSdb *pSdb);
SSdb *sdbInit(SSdbOpt *pOption) { SSdb *sdbInit(SSdbOpt *pOption) {
mDebug("start to init sdb in %s", pOption->path); mDebug("start to init sdb in %s", pOption->path);
SSdb *pSdb = calloc(1, sizeof(SSdb)); SSdb *pSdb = taosMemoryCalloc(1, sizeof(SSdb));
if (pSdb == NULL) { if (pSdb == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed to init sdb since %s", terrstr()); mError("failed to init sdb since %s", terrstr());
...@@ -67,15 +67,15 @@ void sdbCleanup(SSdb *pSdb) { ...@@ -67,15 +67,15 @@ void sdbCleanup(SSdb *pSdb) {
sdbWriteFile(pSdb); sdbWriteFile(pSdb);
if (pSdb->currDir != NULL) { if (pSdb->currDir != NULL) {
tfree(pSdb->currDir); taosMemoryFreeClear(pSdb->currDir);
} }
if (pSdb->syncDir != NULL) { if (pSdb->syncDir != NULL) {
tfree(pSdb->syncDir); taosMemoryFreeClear(pSdb->syncDir);
} }
if (pSdb->tmpDir != NULL) { if (pSdb->tmpDir != NULL) {
tfree(pSdb->tmpDir); taosMemoryFreeClear(pSdb->tmpDir);
} }
for (ESdbType i = 0; i < SDB_MAX; ++i) { for (ESdbType i = 0; i < SDB_MAX; ++i) {
...@@ -102,7 +102,7 @@ void sdbCleanup(SSdb *pSdb) { ...@@ -102,7 +102,7 @@ void sdbCleanup(SSdb *pSdb) {
mDebug("sdb table:%d is cleaned up", i); mDebug("sdb table:%d is cleaned up", i);
} }
free(pSdb); taosMemoryFree(pSdb);
mDebug("sdb is cleaned up"); mDebug("sdb is cleaned up");
} }
......
...@@ -137,7 +137,7 @@ int32_t sdbReadFile(SSdb *pSdb) { ...@@ -137,7 +137,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
int32_t readLen = 0; int32_t readLen = 0;
int64_t ret = 0; int64_t ret = 0;
SSdbRaw *pRaw = malloc(SDB_MAX_SIZE); SSdbRaw *pRaw = taosMemoryMalloc(SDB_MAX_SIZE);
if (pRaw == NULL) { if (pRaw == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed read file since %s", terrstr()); mError("failed read file since %s", terrstr());
...@@ -150,7 +150,7 @@ int32_t sdbReadFile(SSdb *pSdb) { ...@@ -150,7 +150,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ); TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
if (pFile == NULL) { if (pFile == NULL) {
free(pRaw); taosMemoryFree(pRaw);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to read file:%s since %s", file, terrstr()); mError("failed to read file:%s since %s", file, terrstr());
return 0; return 0;
...@@ -159,7 +159,7 @@ int32_t sdbReadFile(SSdb *pSdb) { ...@@ -159,7 +159,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
if (sdbReadFileHead(pSdb, pFile) != 0) { if (sdbReadFileHead(pSdb, pFile) != 0) {
mError("failed to read file:%s head since %s", file, terrstr()); mError("failed to read file:%s head since %s", file, terrstr());
pSdb->curVer = -1; pSdb->curVer = -1;
free(pRaw); taosMemoryFree(pRaw);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return -1; return -1;
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "sdbInt.h" #include "sdbInt.h"
SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) { SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) {
SSdbRaw *pRaw = calloc(1, dataLen + sizeof(SSdbRaw)); SSdbRaw *pRaw = taosMemoryCalloc(1, dataLen + sizeof(SSdbRaw));
if (pRaw == NULL) { if (pRaw == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -33,7 +33,7 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) { ...@@ -33,7 +33,7 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) {
void sdbFreeRaw(SSdbRaw *pRaw) { void sdbFreeRaw(SSdbRaw *pRaw) {
mTrace("raw:%p, is freed", pRaw); mTrace("raw:%p, is freed", pRaw);
free(pRaw); taosMemoryFree(pRaw);
} }
int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val) { int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val) {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "sdbInt.h" #include "sdbInt.h"
SSdbRow *sdbAllocRow(int32_t objSize) { SSdbRow *sdbAllocRow(int32_t objSize) {
SSdbRow *pRow = calloc(1, objSize + sizeof(SSdbRow)); SSdbRow *pRow = taosMemoryCalloc(1, objSize + sizeof(SSdbRow));
if (pRow == NULL) { if (pRow == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -46,5 +46,5 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow) { ...@@ -46,5 +46,5 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow) {
sdbPrintOper(pSdb, pRow, "freeRow"); sdbPrintOper(pSdb, pRow, "freeRow");
mTrace("row:%p, is freed", pRow->pObj); mTrace("row:%p, is freed", pRow->pObj);
tfree(pRow); taosMemoryFreeClear(pRow);
} }
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
#include "qworker.h" #include "qworker.h"
SQnode *qndOpen(const SQnodeOpt *pOption) { SQnode *qndOpen(const SQnodeOpt *pOption) {
SQnode *pQnode = calloc(1, sizeof(SQnode)); SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
if (NULL == pQnode) { if (NULL == pQnode) {
qError("calloc SQnode failed"); qError("calloc SQnode failed");
return NULL; return NULL;
} }
if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, NULL, (void **)&pQnode->pQuery, &pOption->msgCb)) { if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, NULL, (void **)&pQnode->pQuery, &pOption->msgCb)) {
tfree(pQnode); taosMemoryFreeClear(pQnode);
return NULL; return NULL;
} }
...@@ -37,7 +37,7 @@ SQnode *qndOpen(const SQnodeOpt *pOption) { ...@@ -37,7 +37,7 @@ SQnode *qndOpen(const SQnodeOpt *pOption) {
void qndClose(SQnode *pQnode) { void qndClose(SQnode *pQnode) {
qWorkerDestroy((void **)&pQnode->pQuery); qWorkerDestroy((void **)&pQnode->pQuery);
free(pQnode); taosMemoryFree(pQnode);
} }
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { return 0; } int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { return 0; }
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
#include "tuuid.h" #include "tuuid.h"
SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
SSnode *pSnode = calloc(1, sizeof(SSnode)); SSnode *pSnode = taosMemoryCalloc(1, sizeof(SSnode));
if (pSnode == NULL) { if (pSnode == NULL) {
return NULL; return NULL;
} }
pSnode->msgCb = pOption->msgCb; pSnode->msgCb = pOption->msgCb;
pSnode->pMeta = sndMetaNew(); pSnode->pMeta = sndMetaNew();
if (pSnode->pMeta == NULL) { if (pSnode->pMeta == NULL) {
free(pSnode); taosMemoryFree(pSnode);
return NULL; return NULL;
} }
return pSnode; return pSnode;
...@@ -33,19 +33,19 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { ...@@ -33,19 +33,19 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
void sndClose(SSnode *pSnode) { void sndClose(SSnode *pSnode) {
sndMetaDelete(pSnode->pMeta); sndMetaDelete(pSnode->pMeta);
free(pSnode); taosMemoryFree(pSnode);
} }
int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; } int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; }
SStreamMeta *sndMetaNew() { SStreamMeta *sndMetaNew() {
SStreamMeta *pMeta = calloc(1, sizeof(SStreamMeta)); SStreamMeta *pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta));
if (pMeta == NULL) { if (pMeta == NULL) {
return NULL; return NULL;
} }
pMeta->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); pMeta->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
if (pMeta->pHash == NULL) { if (pMeta->pHash == NULL) {
free(pMeta); taosMemoryFree(pMeta);
return NULL; return NULL;
} }
return pMeta; return pMeta;
...@@ -53,7 +53,7 @@ SStreamMeta *sndMetaNew() { ...@@ -53,7 +53,7 @@ SStreamMeta *sndMetaNew() {
void sndMetaDelete(SStreamMeta *pMeta) { void sndMetaDelete(SStreamMeta *pMeta) {
taosHashCleanup(pMeta->pHash); taosHashCleanup(pMeta->pHash);
free(pMeta); taosMemoryFree(pMeta);
} }
int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) {
...@@ -72,9 +72,9 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { ...@@ -72,9 +72,9 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) {
if (pTask == NULL) { if (pTask == NULL) {
return -1; return -1;
} }
free(pTask->exec.qmsg); taosMemoryFree(pTask->exec.qmsg);
// TODO:free executor // TODO:free executor
free(pTask); taosMemoryFree(pTask);
return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t));
} }
...@@ -94,7 +94,7 @@ void sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { ...@@ -94,7 +94,7 @@ void sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) {
// operator exec // operator exec
if (pMsg->msgType == TDMT_SND_TASK_DEPLOY) { if (pMsg->msgType == TDMT_SND_TASK_DEPLOY) {
void *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); void *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
SStreamTask *pTask = malloc(sizeof(SStreamTask)); SStreamTask *pTask = taosMemoryMalloc(sizeof(SStreamTask));
if (pTask == NULL) { if (pTask == NULL) {
ASSERT(0); ASSERT(0);
return; return;
......
...@@ -276,6 +276,8 @@ int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGro ...@@ -276,6 +276,8 @@ int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGro
*/ */
void tsdbCleanupReadHandle(tsdbReaderT queryHandle); void tsdbCleanupReadHandle(tsdbReaderT queryHandle);
int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -30,7 +30,7 @@ static void taosTMemset(void *ptr, int c); ...@@ -30,7 +30,7 @@ static void taosTMemset(void *ptr, int c);
static FORCE_INLINE void *taosTMalloc(size_t size) { static FORCE_INLINE void *taosTMalloc(size_t size) {
if (size <= 0) return NULL; if (size <= 0) return NULL;
void *ret = malloc(size + sizeof(size_t)); void *ret = taosMemoryMalloc(size + sizeof(size_t));
if (ret == NULL) return NULL; if (ret == NULL) return NULL;
*(size_t *)ret = size; *(size_t *)ret = size;
...@@ -58,7 +58,7 @@ static FORCE_INLINE void * taosTRealloc(void *ptr, size_t size) { ...@@ -58,7 +58,7 @@ static FORCE_INLINE void * taosTRealloc(void *ptr, size_t size) {
void * tptr = (void *)((char *)ptr - sizeof(size_t)); void * tptr = (void *)((char *)ptr - sizeof(size_t));
size_t tsize = size + sizeof(size_t); size_t tsize = size + sizeof(size_t);
void* tptr1 = realloc(tptr, tsize); void* tptr1 = taosMemoryRealloc(tptr, tsize);
if (tptr1 == NULL) return NULL; if (tptr1 == NULL) return NULL;
tptr = tptr1; tptr = tptr1;
...@@ -69,7 +69,7 @@ static FORCE_INLINE void * taosTRealloc(void *ptr, size_t size) { ...@@ -69,7 +69,7 @@ static FORCE_INLINE void * taosTRealloc(void *ptr, size_t size) {
static FORCE_INLINE void* taosTZfree(void* ptr) { static FORCE_INLINE void* taosTZfree(void* ptr) {
if (ptr) { if (ptr) {
free((void*)((char*)ptr - sizeof(size_t))); taosMemoryFree((void*)((char*)ptr - sizeof(size_t)));
} }
return NULL; return NULL;
} }
......
...@@ -233,7 +233,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) { ...@@ -233,7 +233,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
// save sma info // save sma info
int32_t len = tEncodeTSma(NULL, pSmaCfg); int32_t len = tEncodeTSma(NULL, pSmaCfg);
pBuf = calloc(len, 1); pBuf = taosMemoryCalloc(len, 1);
if (pBuf == NULL) { if (pBuf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -254,7 +254,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) { ...@@ -254,7 +254,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
metaDBULock(pMeta->pDB); metaDBULock(pMeta->pDB);
// release // release
tfree(pBuf); taosMemoryFreeClear(pBuf);
return 0; return 0;
} }
...@@ -297,7 +297,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) { ...@@ -297,7 +297,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
SSchema *pSchema; SSchema *pSchema;
buf = taosDecodeFixedU32(buf, &pSW->nCols); buf = taosDecodeFixedU32(buf, &pSW->nCols);
pSW->pSchema = (SSchema *)malloc(sizeof(SSchema) * pSW->nCols); pSW->pSchema = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pSW->nCols);
for (int i = 0; i < pSW->nCols; i++) { for (int i = 0; i < pSW->nCols; i++) {
pSchema = pSW->pSchema + i; pSchema = pSW->pSchema + i;
buf = taosDecodeFixedI8(buf, &pSchema->type); buf = taosDecodeFixedI8(buf, &pSchema->type);
...@@ -311,7 +311,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) { ...@@ -311,7 +311,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
static SMetaDB *metaNewDB() { static SMetaDB *metaNewDB() {
SMetaDB *pDB = NULL; SMetaDB *pDB = NULL;
pDB = (SMetaDB *)calloc(1, sizeof(*pDB)); pDB = (SMetaDB *)taosMemoryCalloc(1, sizeof(*pDB));
if (pDB == NULL) { if (pDB == NULL) {
return NULL; return NULL;
} }
...@@ -328,7 +328,7 @@ static void metaFreeDB(SMetaDB *pDB) { ...@@ -328,7 +328,7 @@ static void metaFreeDB(SMetaDB *pDB) {
#if IMPL_WITH_LOCK #if IMPL_WITH_LOCK
taosThreadRwlockDestroy(&pDB->rwlock); taosThreadRwlockDestroy(&pDB->rwlock);
#endif #endif
free(pDB); taosMemoryFree(pDB);
} }
} }
...@@ -463,7 +463,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey ...@@ -463,7 +463,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
DBT *pDbt; DBT *pDbt;
if (pTbCfg->type == META_CHILD_TABLE) { if (pTbCfg->type == META_CHILD_TABLE) {
// pDbt = calloc(2, sizeof(DBT)); // pDbt = taosMemoryCalloc(2, sizeof(DBT));
// // First key is suid // // First key is suid
// pDbt[0].data = &(pTbCfg->ctbCfg.suid); // pDbt[0].data = &(pTbCfg->ctbCfg.suid);
...@@ -545,11 +545,11 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) { ...@@ -545,11 +545,11 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
} }
static void metaClearTbCfg(STbCfg *pTbCfg) { static void metaClearTbCfg(STbCfg *pTbCfg) {
tfree(pTbCfg->name); taosMemoryFreeClear(pTbCfg->name);
if (pTbCfg->type == META_SUPER_TABLE) { if (pTbCfg->type == META_SUPER_TABLE) {
tdFreeSchema(pTbCfg->stbCfg.pTagSchema); tdFreeSchema(pTbCfg->stbCfg.pTagSchema);
} else if (pTbCfg->type == META_CHILD_TABLE) { } else if (pTbCfg->type == META_CHILD_TABLE) {
tfree(pTbCfg->ctbCfg.pTag); taosMemoryFreeClear(pTbCfg->ctbCfg.pTag);
} }
} }
...@@ -574,7 +574,7 @@ STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) { ...@@ -574,7 +574,7 @@ STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
} }
// Decode // Decode
pTbCfg = (STbCfg *)malloc(sizeof(*pTbCfg)); pTbCfg = (STbCfg *)taosMemoryMalloc(sizeof(*pTbCfg));
if (pTbCfg == NULL) { if (pTbCfg == NULL) {
return NULL; return NULL;
} }
...@@ -606,7 +606,7 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) { ...@@ -606,7 +606,7 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
// Decode // Decode
*uid = *(tb_uid_t *)(pkey.data); *uid = *(tb_uid_t *)(pkey.data);
pTbCfg = (STbCfg *)malloc(sizeof(*pTbCfg)); pTbCfg = (STbCfg *)taosMemoryMalloc(sizeof(*pTbCfg));
if (pTbCfg == NULL) { if (pTbCfg == NULL) {
return NULL; return NULL;
} }
...@@ -636,13 +636,13 @@ STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) { ...@@ -636,13 +636,13 @@ STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) {
} }
// Decode // Decode
pCfg = (STSma *)calloc(1, sizeof(STSma)); pCfg = (STSma *)taosMemoryCalloc(1, sizeof(STSma));
if (pCfg == NULL) { if (pCfg == NULL) {
return NULL; return NULL;
} }
if (tDecodeTSma(value.data, pCfg) == NULL) { if (tDecodeTSma(value.data, pCfg) == NULL) {
tfree(pCfg); taosMemoryFreeClear(pCfg);
return NULL; return NULL;
} }
...@@ -675,7 +675,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo ...@@ -675,7 +675,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
// Decode the schema // Decode the schema
pBuf = value.data; pBuf = value.data;
pSW = malloc(sizeof(*pSW)); pSW = taosMemoryMalloc(sizeof(*pSW));
metaDecodeSchema(pBuf, pSW); metaDecodeSchema(pBuf, pSW);
return pSW; return pSW;
...@@ -689,7 +689,7 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) { ...@@ -689,7 +689,7 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
SMTbCursor *pTbCur = NULL; SMTbCursor *pTbCur = NULL;
SMetaDB *pDB = pMeta->pDB; SMetaDB *pDB = pMeta->pDB;
pTbCur = (SMTbCursor *)calloc(1, sizeof(*pTbCur)); pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
if (pTbCur == NULL) { if (pTbCur == NULL) {
return NULL; return NULL;
} }
...@@ -722,7 +722,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) { ...@@ -722,7 +722,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
if (pTbCur->pCur) { if (pTbCur->pCur) {
pTbCur->pCur->close(pTbCur->pCur); pTbCur->pCur->close(pTbCur->pCur);
} }
free(pTbCur); taosMemoryFree(pTbCur);
} }
} }
...@@ -737,8 +737,8 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) { ...@@ -737,8 +737,8 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
pBuf = value.data; pBuf = value.data;
metaDecodeTbInfo(pBuf, &tbCfg); metaDecodeTbInfo(pBuf, &tbCfg);
if (tbCfg.type == META_SUPER_TABLE) { if (tbCfg.type == META_SUPER_TABLE) {
free(tbCfg.name); taosMemoryFree(tbCfg.name);
free(tbCfg.stbCfg.pTagSchema); taosMemoryFree(tbCfg.stbCfg.pTagSchema);
continue; continue;
} else if (tbCfg.type == META_CHILD_TABLE) { } else if (tbCfg.type == META_CHILD_TABLE) {
kvRowFree(tbCfg.ctbCfg.pTag); kvRowFree(tbCfg.ctbCfg.pTag);
...@@ -792,7 +792,7 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) { ...@@ -792,7 +792,7 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
SMetaDB *pDB = pMeta->pDB; SMetaDB *pDB = pMeta->pDB;
int ret; int ret;
pCtbCur = (SMCtbCursor *)calloc(1, sizeof(*pCtbCur)); pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
if (pCtbCur == NULL) { if (pCtbCur == NULL) {
return NULL; return NULL;
} }
...@@ -800,7 +800,7 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) { ...@@ -800,7 +800,7 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
pCtbCur->suid = uid; pCtbCur->suid = uid;
ret = pDB->pCtbIdx->cursor(pDB->pCtbIdx, NULL, &(pCtbCur->pCur), 0); ret = pDB->pCtbIdx->cursor(pDB->pCtbIdx, NULL, &(pCtbCur->pCur), 0);
if (ret != 0) { if (ret != 0) {
free(pCtbCur); taosMemoryFree(pCtbCur);
return NULL; return NULL;
} }
...@@ -813,7 +813,7 @@ void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) { ...@@ -813,7 +813,7 @@ void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) {
pCtbCur->pCur->close(pCtbCur->pCur); pCtbCur->pCur->close(pCtbCur->pCur);
} }
free(pCtbCur); taosMemoryFree(pCtbCur);
} }
} }
...@@ -849,7 +849,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) { ...@@ -849,7 +849,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
SMetaDB *pDB = pMeta->pDB; SMetaDB *pDB = pMeta->pDB;
int ret; int ret;
pCur = (SMSmaCursor *)calloc(1, sizeof(*pCur)); pCur = (SMSmaCursor *)taosMemoryCalloc(1, sizeof(*pCur));
if (pCur == NULL) { if (pCur == NULL) {
return NULL; return NULL;
} }
...@@ -858,7 +858,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) { ...@@ -858,7 +858,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
// TODO: lock? // TODO: lock?
ret = pDB->pCtbIdx->cursor(pDB->pSmaIdx, NULL, &(pCur->pCur), 0); ret = pDB->pCtbIdx->cursor(pDB->pSmaIdx, NULL, &(pCur->pCur), 0);
if (ret != 0) { if (ret != 0) {
free(pCur); taosMemoryFree(pCur);
return NULL; return NULL;
} }
...@@ -871,7 +871,7 @@ void metaCloseSmaCurosr(SMSmaCursor *pCur) { ...@@ -871,7 +871,7 @@ void metaCloseSmaCurosr(SMSmaCursor *pCur) {
pCur->pCur->close(pCur->pCur); pCur->pCur->close(pCur->pCur);
} }
free(pCur); taosMemoryFree(pCur);
} }
} }
...@@ -896,14 +896,14 @@ const char *metaSmaCursorNext(SMSmaCursor *pCur) { ...@@ -896,14 +896,14 @@ const char *metaSmaCursorNext(SMSmaCursor *pCur) {
STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) { STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
STSmaWrapper *pSW = NULL; STSmaWrapper *pSW = NULL;
pSW = calloc(1, sizeof(*pSW)); pSW = taosMemoryCalloc(1, sizeof(*pSW));
if (pSW == NULL) { if (pSW == NULL) {
return NULL; return NULL;
} }
SMSmaCursor *pCur = metaOpenSmaCursor(pMeta, uid); SMSmaCursor *pCur = metaOpenSmaCursor(pMeta, uid);
if (pCur == NULL) { if (pCur == NULL) {
free(pSW); taosMemoryFree(pSW);
return NULL; return NULL;
} }
...@@ -915,11 +915,11 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) { ...@@ -915,11 +915,11 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
// TODO: lock? // TODO: lock?
if (pCur->pCur->pget(pCur->pCur, &skey, NULL, &pval, DB_NEXT) == 0) { if (pCur->pCur->pget(pCur->pCur, &skey, NULL, &pval, DB_NEXT) == 0) {
++pSW->number; ++pSW->number;
STSma *tptr = (STSma *)realloc(pSW->tSma, pSW->number * sizeof(STSma)); STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
if (tptr == NULL) { if (tptr == NULL) {
metaCloseSmaCurosr(pCur); metaCloseSmaCurosr(pCur);
tdDestroyTSmaWrapper(pSW); tdDestroyTSmaWrapper(pSW);
tfree(pSW); taosMemoryFreeClear(pSW);
return NULL; return NULL;
} }
pSW->tSma = tptr; pSW->tSma = tptr;
...@@ -927,7 +927,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) { ...@@ -927,7 +927,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) { if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
metaCloseSmaCurosr(pCur); metaCloseSmaCurosr(pCur);
tdDestroyTSmaWrapper(pSW); tdDestroyTSmaWrapper(pSW);
tfree(pSW); taosMemoryFreeClear(pSW);
return NULL; return NULL;
} }
continue; continue;
......
...@@ -69,7 +69,7 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF ...@@ -69,7 +69,7 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF
SMeta *pMeta; SMeta *pMeta;
size_t psize = strlen(path); size_t psize = strlen(path);
pMeta = (SMeta *)calloc(1, sizeof(*pMeta)); pMeta = (SMeta *)taosMemoryCalloc(1, sizeof(*pMeta));
if (pMeta == NULL) { if (pMeta == NULL) {
return NULL; return NULL;
} }
...@@ -88,8 +88,8 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF ...@@ -88,8 +88,8 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF
static void metaFree(SMeta *pMeta) { static void metaFree(SMeta *pMeta) {
if (pMeta) { if (pMeta) {
tfree(pMeta->path); taosMemoryFreeClear(pMeta->path);
free(pMeta); taosMemoryFree(pMeta);
} }
} }
......
...@@ -47,7 +47,7 @@ int metaOpenDB(SMeta *pMeta) { ...@@ -47,7 +47,7 @@ int metaOpenDB(SMeta *pMeta) {
TDB * pCtbIdx; TDB * pCtbIdx;
int ret; int ret;
pDb = (SMetaDB *)calloc(1, sizeof(*pDb)); pDb = (SMetaDB *)taosMemoryCalloc(1, sizeof(*pDb));
if (pDb == NULL) { if (pDb == NULL) {
return -1; return -1;
} }
......
...@@ -25,7 +25,7 @@ void tqCleanUp() { tqPushMgrCleanUp(); } ...@@ -25,7 +25,7 @@ void tqCleanUp() { tqPushMgrCleanUp(); }
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig, STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig,
SMemAllocatorFactory* allocFac) { SMemAllocatorFactory* allocFac) {
STQ* pTq = malloc(sizeof(STQ)); STQ* pTq = taosMemoryMalloc(sizeof(STQ));
if (pTq == NULL) { if (pTq == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -43,9 +43,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq ...@@ -43,9 +43,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
} }
#endif #endif
pTq->tqMeta = pTq->tqMeta =
tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer, free, 0); tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer, (FTqDelete)taosMemoryFree, 0);
if (pTq->tqMeta == NULL) { if (pTq->tqMeta == NULL) {
free(pTq); taosMemoryFree(pTq);
#if 0 #if 0
allocFac->destroy(allocFac, pTq->tqMemRef.pAllocator); allocFac->destroy(allocFac, pTq->tqMemRef.pAllocator);
#endif #endif
...@@ -56,7 +56,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq ...@@ -56,7 +56,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
pTq->tqPushMgr = tqPushMgrOpen(); pTq->tqPushMgr = tqPushMgrOpen();
if (pTq->tqPushMgr == NULL) { if (pTq->tqPushMgr == NULL) {
// free store // free store
free(pTq); taosMemoryFree(pTq);
return NULL; return NULL;
} }
#endif #endif
...@@ -68,15 +68,15 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq ...@@ -68,15 +68,15 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
void tqClose(STQ* pTq) { void tqClose(STQ* pTq) {
if (pTq) { if (pTq) {
tfree(pTq->path); taosMemoryFreeClear(pTq->path);
free(pTq); taosMemoryFree(pTq);
} }
// TODO // TODO
} }
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version) { int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version) {
if (msgType != TDMT_VND_SUBMIT) return 0; if (msgType != TDMT_VND_SUBMIT) return 0;
void* data = malloc(msgLen); void* data = taosMemoryMalloc(msgLen);
if (data == NULL) { if (data == NULL) {
return -1; return -1;
} }
...@@ -95,7 +95,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi ...@@ -95,7 +95,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
if (pusher->type == TQ_PUSHER_TYPE__STREAM) { if (pusher->type == TQ_PUSHER_TYPE__STREAM) {
STqStreamPusher* streamPusher = (STqStreamPusher*)pusher; STqStreamPusher* streamPusher = (STqStreamPusher*)pusher;
// repack // repack
STqStreamToken* token = malloc(sizeof(STqStreamToken)); STqStreamToken* token = taosMemoryMalloc(sizeof(STqStreamToken));
if (token == NULL) { if (token == NULL) {
taosHashCancelIterate(pTq->tqPushMgr->pHash, pIter); taosHashCancelIterate(pTq->tqPushMgr->pHash, pIter);
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
...@@ -199,9 +199,9 @@ int tqSerializeConsumer(const STqConsumer* pConsumer, STqSerializedHead** ppHead ...@@ -199,9 +199,9 @@ int tqSerializeConsumer(const STqConsumer* pConsumer, STqSerializedHead** ppHead
int32_t sz = tEncodeSTqConsumer(NULL, pConsumer); int32_t sz = tEncodeSTqConsumer(NULL, pConsumer);
if (sz > (*ppHead)->ssize) { if (sz > (*ppHead)->ssize) {
void* tmpPtr = realloc(*ppHead, sizeof(STqSerializedHead) + sz); void* tmpPtr = taosMemoryRealloc(*ppHead, sizeof(STqSerializedHead) + sz);
if (tmpPtr == NULL) { if (tmpPtr == NULL) {
free(*ppHead); taosMemoryFree(*ppHead);
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
} }
...@@ -218,7 +218,7 @@ int tqSerializeConsumer(const STqConsumer* pConsumer, STqSerializedHead** ppHead ...@@ -218,7 +218,7 @@ int tqSerializeConsumer(const STqConsumer* pConsumer, STqSerializedHead** ppHead
int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsumer** ppConsumer) { int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsumer** ppConsumer) {
const void* str = pHead->content; const void* str = pHead->content;
*ppConsumer = calloc(1, sizeof(STqConsumer)); *ppConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (*ppConsumer == NULL) { if (*ppConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
...@@ -392,7 +392,7 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { ...@@ -392,7 +392,7 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
tDecodeSMqSetCVgReq(msg, &req); tDecodeSMqSetCVgReq(msg, &req);
/*printf("vg %d set to consumer from %ld to %ld\n", req.vgId, req.oldConsumerId, req.newConsumerId);*/ /*printf("vg %d set to consumer from %ld to %ld\n", req.vgId, req.oldConsumerId, req.newConsumerId);*/
STqConsumer* pConsumer = calloc(1, sizeof(STqConsumer)); STqConsumer* pConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (pConsumer == NULL) { if (pConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
...@@ -403,10 +403,10 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { ...@@ -403,10 +403,10 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
pConsumer->consumerId = req.consumerId; pConsumer->consumerId = req.consumerId;
pConsumer->epoch = 0; pConsumer->epoch = 0;
STqTopic* pTopic = calloc(1, sizeof(STqTopic)); STqTopic* pTopic = taosMemoryCalloc(1, sizeof(STqTopic));
if (pTopic == NULL) { if (pTopic == NULL) {
taosArrayDestroy(pConsumer->topics); taosArrayDestroy(pConsumer->topics);
free(pConsumer); taosMemoryFree(pConsumer);
return -1; return -1;
} }
strcpy(pTopic->topicName, req.topicName); strcpy(pTopic->topicName, req.topicName);
...@@ -444,7 +444,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) { ...@@ -444,7 +444,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
if (pTask->execType == TASK_EXEC__NONE) return 0; if (pTask->execType == TASK_EXEC__NONE) return 0;
pTask->exec.numOfRunners = parallel; pTask->exec.numOfRunners = parallel;
pTask->exec.runners = calloc(parallel, sizeof(SStreamRunner)); pTask->exec.runners = taosMemoryCalloc(parallel, sizeof(SStreamRunner));
if (pTask->exec.runners == NULL) { if (pTask->exec.runners == NULL) {
return -1; return -1;
} }
...@@ -462,7 +462,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) { ...@@ -462,7 +462,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
} }
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) { int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
SStreamTask* pTask = malloc(sizeof(SStreamTask)); SStreamTask* pTask = taosMemoryMalloc(sizeof(SStreamTask));
if (pTask == NULL) { if (pTask == NULL) {
return -1; return -1;
} }
......
...@@ -70,7 +70,7 @@ static inline int tqReadLastPage(TdFilePtr pFile, STqIdxPageBuf* pBuf) { ...@@ -70,7 +70,7 @@ static inline int tqReadLastPage(TdFilePtr pFile, STqIdxPageBuf* pBuf) {
STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, FTqDeserialize deserializer, STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, FTqDeserialize deserializer,
FTqDelete deleter, int32_t tqConfigFlag) { FTqDelete deleter, int32_t tqConfigFlag) {
STqMetaStore* pMeta = calloc(1, sizeof(STqMetaStore)); STqMetaStore* pMeta = taosMemoryCalloc(1, sizeof(STqMetaStore));
if (pMeta == NULL) { if (pMeta == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -79,10 +79,10 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -79,10 +79,10 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
// concat data file name and index file name // concat data file name and index file name
size_t pathLen = strlen(path); size_t pathLen = strlen(path);
pMeta->dirPath = malloc(pathLen + 1); pMeta->dirPath = taosMemoryMalloc(pathLen + 1);
if (pMeta->dirPath == NULL) { if (pMeta->dirPath == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
free(pMeta); taosMemoryFree(pMeta);
return NULL; return NULL;
} }
strcpy(pMeta->dirPath, path); strcpy(pMeta->dirPath, path);
...@@ -104,7 +104,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -104,7 +104,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
} }
pMeta->pIdxFile = pIdxFile; pMeta->pIdxFile = pIdxFile;
pMeta->unpersistHead = calloc(1, sizeof(STqMetaList)); pMeta->unpersistHead = taosMemoryCalloc(1, sizeof(STqMetaList));
if (pMeta->unpersistHead == NULL) { if (pMeta->unpersistHead == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -129,7 +129,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -129,7 +129,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
// read idx file and load into memory // read idx file and load into memory
STqIdxPageBuf idxBuf; STqIdxPageBuf idxBuf;
STqSerializedHead* serializedObj = malloc(TQ_PAGE_SIZE); STqSerializedHead* serializedObj = taosMemoryMalloc(TQ_PAGE_SIZE);
if (serializedObj == NULL) { if (serializedObj == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
} }
...@@ -145,7 +145,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -145,7 +145,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
ASSERT(idxBuf.head.writeOffset == idxRead); ASSERT(idxBuf.head.writeOffset == idxRead);
// loop read every entry // loop read every entry
for (int i = 0; i < idxBuf.head.writeOffset - TQ_IDX_PAGE_HEAD_SIZE; i += TQ_IDX_SIZE) { for (int i = 0; i < idxBuf.head.writeOffset - TQ_IDX_PAGE_HEAD_SIZE; i += TQ_IDX_SIZE) {
STqMetaList* pNode = calloc(1, sizeof(STqMetaList)); STqMetaList* pNode = taosMemoryCalloc(1, sizeof(STqMetaList));
if (pNode == NULL) { if (pNode == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
// TODO: free memory // TODO: free memory
...@@ -154,7 +154,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -154,7 +154,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
taosLSeekFile(pFile, pNode->handle.offset, SEEK_SET); taosLSeekFile(pFile, pNode->handle.offset, SEEK_SET);
if (allocated < pNode->handle.serializedSize) { if (allocated < pNode->handle.serializedSize) {
void* ptr = realloc(serializedObj, pNode->handle.serializedSize); void* ptr = taosMemoryRealloc(serializedObj, pNode->handle.serializedSize);
if (ptr == NULL) { if (ptr == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
// TODO: free memory // TODO: free memory
...@@ -225,11 +225,11 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -225,11 +225,11 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
if (pBucketNode->handle.valueInTxn && pBucketNode->handle.valueInTxn != TQ_DELETE_TOKEN) { if (pBucketNode->handle.valueInTxn && pBucketNode->handle.valueInTxn != TQ_DELETE_TOKEN) {
pMeta->pDeleter(pBucketNode->handle.valueInTxn); pMeta->pDeleter(pBucketNode->handle.valueInTxn);
} }
free(pBucketNode); taosMemoryFree(pBucketNode);
} }
} }
} }
free(serializedObj); taosMemoryFree(serializedObj);
return pMeta; return pMeta;
} }
...@@ -252,13 +252,13 @@ int32_t tqStoreClose(STqMetaStore* pMeta) { ...@@ -252,13 +252,13 @@ int32_t tqStoreClose(STqMetaStore* pMeta) {
pMeta->pDeleter(pNode->handle.valueInUse); pMeta->pDeleter(pNode->handle.valueInUse);
} }
STqMetaList* next = pNode->next; STqMetaList* next = pNode->next;
free(pNode); taosMemoryFree(pNode);
pNode = next; pNode = next;
} }
} }
free(pMeta->dirPath); taosMemoryFree(pMeta->dirPath);
free(pMeta->unpersistHead); taosMemoryFree(pMeta->unpersistHead);
free(pMeta); taosMemoryFree(pMeta);
return 0; return 0;
} }
...@@ -277,14 +277,14 @@ int32_t tqStoreDelete(STqMetaStore* pMeta) { ...@@ -277,14 +277,14 @@ int32_t tqStoreDelete(STqMetaStore* pMeta) {
pMeta->pDeleter(pNode->handle.valueInUse); pMeta->pDeleter(pNode->handle.valueInUse);
} }
STqMetaList* next = pNode->next; STqMetaList* next = pNode->next;
free(pNode); taosMemoryFree(pNode);
pNode = next; pNode = next;
} }
} }
free(pMeta->unpersistHead); taosMemoryFree(pMeta->unpersistHead);
taosRemoveDir(pMeta->dirPath); taosRemoveDir(pMeta->dirPath);
free(pMeta->dirPath); taosMemoryFree(pMeta->dirPath);
free(pMeta); taosMemoryFree(pMeta);
return 0; return 0;
} }
...@@ -293,7 +293,7 @@ int32_t tqStorePersist(STqMetaStore* pMeta) { ...@@ -293,7 +293,7 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
int64_t* bufPtr = (int64_t*)idxBuf.buffer; int64_t* bufPtr = (int64_t*)idxBuf.buffer;
STqMetaList* pHead = pMeta->unpersistHead; STqMetaList* pHead = pMeta->unpersistHead;
STqMetaList* pNode = pHead->unpersistNext; STqMetaList* pNode = pHead->unpersistNext;
STqSerializedHead* pSHead = malloc(sizeof(STqSerializedHead)); STqSerializedHead* pSHead = taosMemoryMalloc(sizeof(STqSerializedHead));
if (pSHead == NULL) { if (pSHead == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
...@@ -383,12 +383,12 @@ int32_t tqStorePersist(STqMetaStore* pMeta) { ...@@ -383,12 +383,12 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
ASSERT(pBucketNode->next == pNode); ASSERT(pBucketNode->next == pNode);
pBucketNode->next = pNode->next; pBucketNode->next = pNode->next;
} }
free(pNode); taosMemoryFree(pNode);
} }
} }
// write left bytes // write left bytes
free(pSHead); taosMemoryFree(pSHead);
// TODO: write new version in tfile // TODO: write new version in tfile
if ((char*)bufPtr != idxBuf.buffer) { if ((char*)bufPtr != idxBuf.buffer) {
int nBytes = taosWriteFile(pMeta->pIdxFile, &idxBuf, idxBuf.head.writeOffset); int nBytes = taosWriteFile(pMeta->pIdxFile, &idxBuf, idxBuf.head.writeOffset);
...@@ -416,7 +416,7 @@ static int32_t tqHandlePutCommitted(STqMetaStore* pMeta, int64_t key, void* valu ...@@ -416,7 +416,7 @@ static int32_t tqHandlePutCommitted(STqMetaStore* pMeta, int64_t key, void* valu
pNode = pNode->next; pNode = pNode->next;
} }
} }
STqMetaList* pNewNode = calloc(1, sizeof(STqMetaList)); STqMetaList* pNewNode = taosMemoryCalloc(1, sizeof(STqMetaList));
if (pNewNode == NULL) { if (pNewNode == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
...@@ -488,7 +488,7 @@ static inline int32_t tqHandlePutImpl(STqMetaStore* pMeta, int64_t key, void* va ...@@ -488,7 +488,7 @@ static inline int32_t tqHandlePutImpl(STqMetaStore* pMeta, int64_t key, void* va
pNode = pNode->next; pNode = pNode->next;
} }
} }
STqMetaList* pNewNode = calloc(1, sizeof(STqMetaList)); STqMetaList* pNewNode = taosMemoryCalloc(1, sizeof(STqMetaList));
if (pNewNode == NULL) { if (pNewNode == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
...@@ -504,7 +504,7 @@ static inline int32_t tqHandlePutImpl(STqMetaStore* pMeta, int64_t key, void* va ...@@ -504,7 +504,7 @@ static inline int32_t tqHandlePutImpl(STqMetaStore* pMeta, int64_t key, void* va
int32_t tqHandleMovePut(STqMetaStore* pMeta, int64_t key, void* value) { return tqHandlePutImpl(pMeta, key, value); } int32_t tqHandleMovePut(STqMetaStore* pMeta, int64_t key, void* value) { return tqHandlePutImpl(pMeta, key, value); }
int32_t tqHandleCopyPut(STqMetaStore* pMeta, int64_t key, void* value, size_t vsize) { int32_t tqHandleCopyPut(STqMetaStore* pMeta, int64_t key, void* value, size_t vsize) {
void* vmem = malloc(vsize); void* vmem = taosMemoryMalloc(vsize);
if (vmem == NULL) { if (vmem == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -31,7 +31,7 @@ struct STqOffsetStore { ...@@ -31,7 +31,7 @@ struct STqOffsetStore {
}; };
STqOffsetStore* STqOffsetOpen(STqOffsetCfg* pCfg) { STqOffsetStore* STqOffsetOpen(STqOffsetCfg* pCfg) {
STqOffsetStore* pStore = malloc(sizeof(STqOffsetStore)); STqOffsetStore* pStore = taosMemoryMalloc(sizeof(STqOffsetStore));
if (pStore == NULL) { if (pStore == NULL) {
return NULL; return NULL;
} }
......
...@@ -32,7 +32,7 @@ void tqPushMgrCleanUp() { ...@@ -32,7 +32,7 @@ void tqPushMgrCleanUp() {
} }
STqPushMgr* tqPushMgrOpen() { STqPushMgr* tqPushMgrOpen() {
STqPushMgr* mgr = malloc(sizeof(STqPushMgr)); STqPushMgr* mgr = taosMemoryMalloc(sizeof(STqPushMgr));
if (mgr == NULL) { if (mgr == NULL) {
return NULL; return NULL;
} }
...@@ -42,11 +42,11 @@ STqPushMgr* tqPushMgrOpen() { ...@@ -42,11 +42,11 @@ STqPushMgr* tqPushMgrOpen() {
void tqPushMgrClose(STqPushMgr* pushMgr) { void tqPushMgrClose(STqPushMgr* pushMgr) {
taosHashCleanup(pushMgr->pHash); taosHashCleanup(pushMgr->pHash);
free(pushMgr); taosMemoryFree(pushMgr);
} }
STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t consumerId, int64_t ttl) { STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t consumerId, int64_t ttl) {
STqClientPusher* clientPusher = malloc(sizeof(STqClientPusher)); STqClientPusher* clientPusher = taosMemoryMalloc(sizeof(STqClientPusher));
if (clientPusher == NULL) { if (clientPusher == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -57,7 +57,7 @@ STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t c ...@@ -57,7 +57,7 @@ STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t c
clientPusher->ttl = ttl; clientPusher->ttl = ttl;
if (taosHashPut(pushMgr->pHash, &consumerId, sizeof(int64_t), &clientPusher, sizeof(void*)) < 0) { if (taosHashPut(pushMgr->pHash, &consumerId, sizeof(int64_t), &clientPusher, sizeof(void*)) < 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
free(clientPusher); taosMemoryFree(clientPusher);
// TODO send rsp back // TODO send rsp back
return NULL; return NULL;
} }
...@@ -65,7 +65,7 @@ STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t c ...@@ -65,7 +65,7 @@ STqClientPusher* tqAddClientPusher(STqPushMgr* pushMgr, SRpcMsg* pMsg, int64_t c
} }
STqStreamPusher* tqAddStreamPusher(STqPushMgr* pushMgr, int64_t streamId, SEpSet* pEpSet) { STqStreamPusher* tqAddStreamPusher(STqPushMgr* pushMgr, int64_t streamId, SEpSet* pEpSet) {
STqStreamPusher* streamPusher = malloc(sizeof(STqStreamPusher)); STqStreamPusher* streamPusher = taosMemoryMalloc(sizeof(STqStreamPusher));
if (streamPusher == NULL) { if (streamPusher == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -77,7 +77,7 @@ STqStreamPusher* tqAddStreamPusher(STqPushMgr* pushMgr, int64_t streamId, SEpSet ...@@ -77,7 +77,7 @@ STqStreamPusher* tqAddStreamPusher(STqPushMgr* pushMgr, int64_t streamId, SEpSet
if (taosHashPut(pushMgr->pHash, &streamId, sizeof(int64_t), &streamPusher, sizeof(void*)) < 0) { if (taosHashPut(pushMgr->pHash, &streamId, sizeof(int64_t), &streamPusher, sizeof(void*)) < 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
free(streamPusher); taosMemoryFree(streamPusher);
return NULL; return NULL;
} }
return streamPusher; return streamPusher;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "vnode.h" #include "vnode.h"
STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) { STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) {
STqReadHandle* pReadHandle = malloc(sizeof(STqReadHandle)); STqReadHandle* pReadHandle = taosMemoryMalloc(sizeof(STqReadHandle));
if (pReadHandle == NULL) { if (pReadHandle == NULL) {
return NULL; return NULL;
} }
...@@ -143,7 +143,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) { ...@@ -143,7 +143,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colInfo.info.colId = pColSchema->colId; colInfo.info.colId = pColSchema->colId;
colInfo.info.type = pColSchema->type; colInfo.info.type = pColSchema->type;
colInfo.pData = calloc(1, sz); colInfo.pData = taosMemoryCalloc(1, sz);
if (colInfo.pData == NULL) { if (colInfo.pData == NULL) {
// TODO free // TODO free
taosArrayDestroy(pArray); taosArrayDestroy(pArray);
...@@ -173,7 +173,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) { ...@@ -173,7 +173,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colInfo.info.colId = colId; colInfo.info.colId = colId;
colInfo.info.type = pColSchema->type; colInfo.info.type = pColSchema->type;
colInfo.pData = calloc(1, sz); colInfo.pData = taosMemoryCalloc(1, sz);
if (colInfo.pData == NULL) { if (colInfo.pData == NULL) {
// TODO free // TODO free
taosArrayDestroy(pArray); taosArrayDestroy(pArray);
......
...@@ -51,7 +51,7 @@ void tsdbCloseDBF(SDBFile *pDBF) { ...@@ -51,7 +51,7 @@ void tsdbCloseDBF(SDBFile *pDBF) {
tsdbCloseBDBDb(pDBF->pDB); tsdbCloseBDBDb(pDBF->pDB);
pDBF->pDB = NULL; pDBF->pDB = NULL;
} }
tfree(pDBF->path); taosMemoryFreeClear(pDBF->path);
} }
int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) { int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) {
...@@ -159,7 +159,7 @@ void *tsdbGetSmaDataByKey(SDBFile *pDBF, void* key, uint32_t keySize, uint32_t * ...@@ -159,7 +159,7 @@ void *tsdbGetSmaDataByKey(SDBFile *pDBF, void* key, uint32_t keySize, uint32_t *
return NULL; return NULL;
} }
result = calloc(1, value1.size); result = taosMemoryCalloc(1, value1.size);
if (result == NULL) { if (result == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -403,7 +403,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) { ...@@ -403,7 +403,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
STbData *pTbData; STbData *pTbData;
pCommith->niters = SL_SIZE(pMem->pSlIdx); pCommith->niters = SL_SIZE(pMem->pSlIdx);
pCommith->iters = (SCommitIter *)calloc(pCommith->niters, sizeof(SCommitIter)); pCommith->iters = (SCommitIter *)taosMemoryCalloc(pCommith->niters, sizeof(SCommitIter));
if (pCommith->iters == NULL) { if (pCommith->iters == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1; return -1;
...@@ -424,7 +424,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) { ...@@ -424,7 +424,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
pCommitIter->pIter = tSkipListCreateIter(pTbData->pData); pCommitIter->pIter = tSkipListCreateIter(pTbData->pData);
tSkipListIterNext(pCommitIter->pIter); tSkipListIterNext(pCommitIter->pIter);
pCommitIter->pTable = (STable *)malloc(sizeof(STable)); pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable));
pCommitIter->pTable->uid = pTbData->uid; pCommitIter->pTable->uid = pTbData->uid;
pCommitIter->pTable->tid = pTbData->uid; pCommitIter->pTable->tid = pTbData->uid;
pCommitIter->pTable->pSchema = metaGetTbTSchema(pRepo->pMeta, pTbData->uid, 0); pCommitIter->pTable->pSchema = metaGetTbTSchema(pRepo->pMeta, pTbData->uid, 0);
...@@ -439,10 +439,10 @@ static void tsdbDestroyCommitIters(SCommitH *pCommith) { ...@@ -439,10 +439,10 @@ static void tsdbDestroyCommitIters(SCommitH *pCommith) {
for (int i = 1; i < pCommith->niters; i++) { for (int i = 1; i < pCommith->niters; i++) {
tSkipListDestroyIter(pCommith->iters[i].pIter); tSkipListDestroyIter(pCommith->iters[i].pIter);
tdFreeSchema(pCommith->iters[i].pTable->pSchema); tdFreeSchema(pCommith->iters[i].pTable->pSchema);
free(pCommith->iters[i].pTable); taosMemoryFree(pCommith->iters[i].pTable);
} }
free(pCommith->iters); taosMemoryFree(pCommith->iters);
pCommith->iters = NULL; pCommith->iters = NULL;
pCommith->niters = 0; pCommith->niters = 0;
} }
...@@ -985,7 +985,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) { ...@@ -985,7 +985,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
// SKVRecord *pRecord; // SKVRecord *pRecord;
// void *pBuf = NULL; // void *pBuf = NULL;
// pBuf = malloc((size_t)maxBufSize); // pBuf = taosMemoryMalloc((size_t)maxBufSize);
// if (pBuf == NULL) { // if (pBuf == NULL) {
// goto _err; // goto _err;
// } // }
...@@ -1006,7 +1006,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) { ...@@ -1006,7 +1006,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
// } // }
// if (pRecord->size > maxBufSize) { // if (pRecord->size > maxBufSize) {
// maxBufSize = pRecord->size; // maxBufSize = pRecord->size;
// void* tmp = realloc(pBuf, (size_t)maxBufSize); // void* tmp = taosMemoryRealloc(pBuf, (size_t)maxBufSize);
// if (tmp == NULL) { // if (tmp == NULL) {
// goto _err; // goto _err;
// } // }
...@@ -1059,7 +1059,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) { ...@@ -1059,7 +1059,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
// pfs->metaCacheComp = NULL; // pfs->metaCacheComp = NULL;
// } // }
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// ASSERT(mf.info.nDels == 0); // ASSERT(mf.info.nDels == 0);
// ASSERT(mf.info.tombSize == 0); // ASSERT(mf.info.tombSize == 0);
......
...@@ -134,7 +134,7 @@ static void *tsdbDecodeFSStatus(STsdb*pRepo, void *buf, SFSStatus *pStatus) { ...@@ -134,7 +134,7 @@ static void *tsdbDecodeFSStatus(STsdb*pRepo, void *buf, SFSStatus *pStatus) {
} }
static SFSStatus *tsdbNewFSStatus(int maxFSet) { static SFSStatus *tsdbNewFSStatus(int maxFSet) {
SFSStatus *pStatus = (SFSStatus *)calloc(1, sizeof(*pStatus)); SFSStatus *pStatus = (SFSStatus *)taosMemoryCalloc(1, sizeof(*pStatus));
if (pStatus == NULL) { if (pStatus == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -145,7 +145,7 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) { ...@@ -145,7 +145,7 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) {
pStatus->df = taosArrayInit(maxFSet, sizeof(SDFileSet)); pStatus->df = taosArrayInit(maxFSet, sizeof(SDFileSet));
if (pStatus->df == NULL) { if (pStatus->df == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
free(pStatus); taosMemoryFree(pStatus);
return NULL; return NULL;
} }
...@@ -155,7 +155,7 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) { ...@@ -155,7 +155,7 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) {
static SFSStatus *tsdbFreeFSStatus(SFSStatus *pStatus) { static SFSStatus *tsdbFreeFSStatus(SFSStatus *pStatus) {
if (pStatus) { if (pStatus) {
pStatus->df = taosArrayDestroy(pStatus->df); pStatus->df = taosArrayDestroy(pStatus->df);
free(pStatus); taosMemoryFree(pStatus);
} }
return NULL; return NULL;
...@@ -197,7 +197,7 @@ STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) { ...@@ -197,7 +197,7 @@ STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) {
int maxFSet = TSDB_MAX_FSETS(keep, days); int maxFSet = TSDB_MAX_FSETS(keep, days);
STsdbFS *pfs; STsdbFS *pfs;
pfs = (STsdbFS *)calloc(1, sizeof(*pfs)); pfs = (STsdbFS *)taosMemoryCalloc(1, sizeof(*pfs));
if (pfs == NULL) { if (pfs == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -206,7 +206,7 @@ STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) { ...@@ -206,7 +206,7 @@ STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) {
int code = taosThreadRwlockInit(&(pfs->lock), NULL); int code = taosThreadRwlockInit(&(pfs->lock), NULL);
if (code) { if (code) {
terrno = TAOS_SYSTEM_ERROR(code); terrno = TAOS_SYSTEM_ERROR(code);
free(pfs); taosMemoryFree(pfs);
return NULL; return NULL;
} }
...@@ -242,7 +242,7 @@ void *tsdbFreeFS(STsdbFS *pfs) { ...@@ -242,7 +242,7 @@ void *tsdbFreeFS(STsdbFS *pfs) {
pfs->metaCache = NULL; pfs->metaCache = NULL;
pfs->cstatus = tsdbFreeFSStatus(pfs->cstatus); pfs->cstatus = tsdbFreeFSStatus(pfs->cstatus);
taosThreadRwlockDestroy(&(pfs->lock)); taosThreadRwlockDestroy(&(pfs->lock));
free(pfs); taosMemoryFree(pfs);
} }
return NULL; return NULL;
...@@ -853,7 +853,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -853,7 +853,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// } // }
// if (recoverMeta) { // if (recoverMeta) {
// pBuf = malloc((size_t)maxBufSize); // pBuf = taosMemoryMalloc((size_t)maxBufSize);
// if (pBuf == NULL) { // if (pBuf == NULL) {
// terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; // terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
...@@ -865,7 +865,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -865,7 +865,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// if (tsdbSeekMFile(pMFile, pRecord->offset + sizeof(SKVRecord), SEEK_SET) < 0) { // if (tsdbSeekMFile(pMFile, pRecord->offset + sizeof(SKVRecord), SEEK_SET) < 0) {
// tsdbError("vgId:%d failed to seek file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), // tsdbError("vgId:%d failed to seek file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile),
// tstrerror(terrno)); // tstrerror(terrno));
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
// return -1; // return -1;
// } // }
...@@ -874,7 +874,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -874,7 +874,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// if (nread < 0) { // if (nread < 0) {
// tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), // tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile),
// tstrerror(terrno)); // tstrerror(terrno));
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
// return -1; // return -1;
// } // }
...@@ -883,7 +883,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -883,7 +883,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// tsdbError("vgId:%d failed to read file %s since file corrupted, expected read:%" PRId64 " actual read:%d", // tsdbError("vgId:%d failed to read file %s since file corrupted, expected read:%" PRId64 " actual read:%d",
// REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), pRecord->size, nread); // REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), pRecord->size, nread);
// terrno = TSDB_CODE_TDB_FILE_CORRUPTED; // terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
// return -1; // return -1;
// } // }
...@@ -891,7 +891,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -891,7 +891,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// if (tsdbRestoreTable(pRepo, pBuf, (int)pRecord->size) < 0) { // if (tsdbRestoreTable(pRepo, pBuf, (int)pRecord->size) < 0) {
// tsdbError("vgId:%d failed to restore table, uid %" PRId64 ", since %s" PRIu64, REPO_ID(pRepo), pRecord->uid, // tsdbError("vgId:%d failed to restore table, uid %" PRId64 ", since %s" PRIu64, REPO_ID(pRepo), pRecord->uid,
// tstrerror(terrno)); // tstrerror(terrno));
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
// return -1; // return -1;
// } // }
...@@ -903,7 +903,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) { ...@@ -903,7 +903,7 @@ static int tsdbScanAndTryFixFS(STsdb *pRepo) {
// } // }
// tsdbCloseMFile(pMFile); // tsdbCloseMFile(pMFile);
// tfree(pBuf); // taosMemoryFreeClear(pBuf);
// return 0; // return 0;
// } // }
......
...@@ -85,7 +85,7 @@ void *tsdbDecodeSMFileEx(void *buf, SMFile *pMFile) { ...@@ -85,7 +85,7 @@ void *tsdbDecodeSMFileEx(void *buf, SMFile *pMFile) {
strncpy(TSDB_FILE_FULL_NAME(pMFile), aname, TSDB_FILENAME_LEN); strncpy(TSDB_FILE_FULL_NAME(pMFile), aname, TSDB_FILENAME_LEN);
TSDB_FILE_SET_CLOSED(pMFile); TSDB_FILE_SET_CLOSED(pMFile);
tfree(aname); taosMemoryFreeClear(aname);
return buf; return buf;
} }
...@@ -119,10 +119,10 @@ int tsdbCreateMFile(SMFile *pMFile, bool updateHeader) { ...@@ -119,10 +119,10 @@ int tsdbCreateMFile(SMFile *pMFile, bool updateHeader) {
// Try to create directory recursively // Try to create directory recursively
char *s = strdup(TFILE_REL_NAME(&(pMFile->f))); char *s = strdup(TFILE_REL_NAME(&(pMFile->f)));
if (tfsMkdirRecurAt(dirname(s), TSDB_FILE_LEVEL(pMFile), TSDB_FILE_ID(pMFile)) < 0) { if (tfsMkdirRecurAt(dirname(s), TSDB_FILE_LEVEL(pMFile), TSDB_FILE_ID(pMFile)) < 0) {
tfree(s); taosMemoryFreeClear(s);
return -1; return -1;
} }
tfree(s); taosMemoryFreeClear(s);
pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755); pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755);
if (pMFile->fd < 0) { if (pMFile->fd < 0) {
...@@ -352,7 +352,7 @@ static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) { ...@@ -352,7 +352,7 @@ static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) {
buf = taosDecodeString(buf, &aname); buf = taosDecodeString(buf, &aname);
strncpy(TSDB_FILE_FULL_NAME(pDFile), aname, TSDB_FILENAME_LEN); strncpy(TSDB_FILE_FULL_NAME(pDFile), aname, TSDB_FILENAME_LEN);
TSDB_FILE_SET_CLOSED(pDFile); TSDB_FILE_SET_CLOSED(pDFile);
tfree(aname); taosMemoryFreeClear(aname);
return buf; return buf;
} }
...@@ -366,10 +366,10 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T ...@@ -366,10 +366,10 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T
// Try to create directory recursively // Try to create directory recursively
char *s = strdup(TSDB_FILE_REL_NAME(pDFile)); char *s = strdup(TSDB_FILE_REL_NAME(pDFile));
if (tfsMkdirRecurAt(pRepo->pTfs, taosDirName(s), TSDB_FILE_DID(pDFile)) < 0) { if (tfsMkdirRecurAt(pRepo->pTfs, taosDirName(s), TSDB_FILE_DID(pDFile)) < 0) {
tfree(s); taosMemoryFreeClear(s);
return -1; return -1;
} }
tfree(s); taosMemoryFreeClear(s);
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pDFile->pFile == NULL) { if (pDFile->pFile == NULL) {
...@@ -692,7 +692,7 @@ int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype ...@@ -692,7 +692,7 @@ int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype
} }
} }
tfree(p); taosMemoryFreeClear(p);
return 0; return 0;
} }
......
...@@ -68,7 +68,7 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, ...@@ -68,7 +68,7 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
SMeta *pMeta, STfs *pTfs) { SMeta *pMeta, STfs *pTfs) {
STsdb *pTsdb = NULL; STsdb *pTsdb = NULL;
pTsdb = (STsdb *)calloc(1, sizeof(STsdb)); pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb));
if (pTsdb == NULL) { if (pTsdb == NULL) {
// TODO: handle error // TODO: handle error
return NULL; return NULL;
...@@ -93,8 +93,8 @@ static void tsdbFree(STsdb *pTsdb) { ...@@ -93,8 +93,8 @@ static void tsdbFree(STsdb *pTsdb) {
tsdbFreeSmaEnv(pTsdb->pRSmaEnv); tsdbFreeSmaEnv(pTsdb->pRSmaEnv);
tsdbFreeSmaEnv(pTsdb->pTSmaEnv); tsdbFreeSmaEnv(pTsdb->pTSmaEnv);
tsdbFreeFS(pTsdb->fs); tsdbFreeFS(pTsdb->fs);
tfree(pTsdb->path); taosMemoryFreeClear(pTsdb->path);
free(pTsdb); taosMemoryFree(pTsdb);
} }
} }
...@@ -507,7 +507,7 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t ...@@ -507,7 +507,7 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t
magic = pFile->info.magic; magic = pFile->info.magic;
char *tfname = strdup(fname); char *tfname = strdup(fname);
sprintf(name, "tsdb/%s/%s", TSDB_DATA_DIR_NAME, basename(tfname)); sprintf(name, "tsdb/%s/%s", TSDB_DATA_DIR_NAME, basename(tfname));
tfree(tfname); taosMemoryFreeClear(tfname);
} else { } else {
if ((pFGroup->fileId + 1) * TSDB_FILE_TYPE_MAX - 1 < (int)eindex) { if ((pFGroup->fileId + 1) * TSDB_FILE_TYPE_MAX - 1 < (int)eindex) {
SFile *pFile = &pFGroup->files[0]; SFile *pFile = &pFGroup->files[0];
...@@ -516,17 +516,17 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t ...@@ -516,17 +516,17 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t
magic = pFile->info.magic; magic = pFile->info.magic;
char *tfname = strdup(fname); char *tfname = strdup(fname);
sprintf(name, "tsdb/%s/%s", TSDB_DATA_DIR_NAME, basename(tfname)); sprintf(name, "tsdb/%s/%s", TSDB_DATA_DIR_NAME, basename(tfname));
tfree(tfname); taosMemoryFreeClear(tfname);
} else { } else {
return 0; return 0;
} }
} }
} }
} else { // get the named file at the specified index. If not there, return 0 } else { // get the named file at the specified index. If not there, return 0
fname = malloc(256); fname = taosMemoryMalloc(256);
sprintf(fname, "%s/vnode/vnode%d/%s", tfsGetPrimaryPath(pRepo->pTfs), REPO_ID(pRepo), name); sprintf(fname, "%s/vnode/vnode%d/%s", tfsGetPrimaryPath(pRepo->pTfs), REPO_ID(pRepo), name);
if (access(fname, F_OK) != 0) { if (access(fname, F_OK) != 0) {
tfree(fname); taosMemoryFreeClear(fname);
return 0; return 0;
} }
if (*index == TSDB_META_FILE_INDEX) { // get meta file if (*index == TSDB_META_FILE_INDEX) { // get meta file
...@@ -536,19 +536,19 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t ...@@ -536,19 +536,19 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t
sprintf(tfname, "vnode/vnode%d/tsdb/%s/%s", REPO_ID(pRepo), TSDB_DATA_DIR_NAME, basename(name)); sprintf(tfname, "vnode/vnode%d/tsdb/%s/%s", REPO_ID(pRepo), TSDB_DATA_DIR_NAME, basename(name));
tsdbGetFileInfoImpl(tfname, &magic, size); tsdbGetFileInfoImpl(tfname, &magic, size);
} }
tfree(fname); taosMemoryFreeClear(fname);
return magic; return magic;
} }
if (stat(fname, &fState) < 0) { if (stat(fname, &fState) < 0) {
tfree(fname); taosMemoryFreeClear(fname);
return 0; return 0;
} }
*size = fState.st_size; *size = fState.st_size;
// magic = *size; // magic = *size;
tfree(fname); taosMemoryFreeClear(fname);
return magic; return magic;
#endif #endif
} }
...@@ -674,7 +674,7 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { ...@@ -674,7 +674,7 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
} }
static STsdbRepo *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) { static STsdbRepo *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
STsdbRepo *pRepo = (STsdbRepo *)calloc(1, sizeof(*pRepo)); STsdbRepo *pRepo = (STsdbRepo *)taosMemoryCalloc(1, sizeof(*pRepo));
if (pRepo == NULL) { if (pRepo == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -748,7 +748,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) { ...@@ -748,7 +748,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
// tsdbFreeMemTable(pRepo->imem); // tsdbFreeMemTable(pRepo->imem);
tsem_destroy(&(pRepo->readyToCommit)); tsem_destroy(&(pRepo->readyToCommit));
taosThreadMutexDestroy(&pRepo->mutex); taosThreadMutexDestroy(&pRepo->mutex);
free(pRepo); taosMemoryFree(pRepo);
} }
} }
...@@ -820,7 +820,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea ...@@ -820,7 +820,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea
goto out; goto out;
} }
pBlockStatis = calloc(numColumns, sizeof(SDataStatis)); pBlockStatis = taosMemoryCalloc(numColumns, sizeof(SDataStatis));
if (pBlockStatis == NULL) { if (pBlockStatis == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
err = -1; err = -1;
...@@ -886,7 +886,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea ...@@ -886,7 +886,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea
// save not-null column // save not-null column
uint16_t bytes = IS_VAR_DATA_TYPE(pCol->type) ? varDataTLen(pColData) : pCol->bytes; uint16_t bytes = IS_VAR_DATA_TYPE(pCol->type) ? varDataTLen(pColData) : pCol->bytes;
SDataCol *pLastCol = &(pTable->lastCols[idx]); SDataCol *pLastCol = &(pTable->lastCols[idx]);
pLastCol->pData = malloc(bytes); pLastCol->pData = taosMemoryMalloc(bytes);
pLastCol->bytes = bytes; pLastCol->bytes = bytes;
pLastCol->colId = pCol->colId; pLastCol->colId = pCol->colId;
memcpy(pLastCol->pData, value, bytes); memcpy(pLastCol->pData, value, bytes);
...@@ -907,7 +907,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea ...@@ -907,7 +907,7 @@ static int tsdbRestoreLastColumns(STsdbRepo *pRepo, STable *pTable, SReadH* pRea
out: out:
taosTZfree(row); taosTZfree(row);
tfree(pBlockStatis); taosMemoryFreeClear(pBlockStatis);
if (err == 0 && numColumns <= pTable->restoreColumnNum) { if (err == 0 && numColumns <= pTable->restoreColumnNum) {
pTable->hasRestoreLastColumn = true; pTable->hasRestoreLastColumn = true;
......
...@@ -25,7 +25,7 @@ static char * tsdbTbDataGetUid(const void *arg); ...@@ -25,7 +25,7 @@ static char * tsdbTbDataGetUid(const void *arg);
static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row); static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row);
STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) {
STsdbMemTable *pMemTable = (STsdbMemTable *)calloc(1, sizeof(*pMemTable)); STsdbMemTable *pMemTable = (STsdbMemTable *)taosMemoryCalloc(1, sizeof(*pMemTable));
if (pMemTable == NULL) { if (pMemTable == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -38,7 +38,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { ...@@ -38,7 +38,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) {
pMemTable->nRow = 0; pMemTable->nRow = 0;
pMemTable->pMA = pTsdb->pmaf->create(pTsdb->pmaf); pMemTable->pMA = pTsdb->pmaf->create(pTsdb->pmaf);
if (pMemTable->pMA == NULL) { if (pMemTable->pMA == NULL) {
free(pMemTable); taosMemoryFree(pMemTable);
return NULL; return NULL;
} }
...@@ -47,7 +47,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { ...@@ -47,7 +47,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) {
tSkipListCreate(5, TSDB_DATA_TYPE_BIGINT, sizeof(tb_uid_t), tsdbTbDataComp, SL_DISCARD_DUP_KEY, tsdbTbDataGetUid); tSkipListCreate(5, TSDB_DATA_TYPE_BIGINT, sizeof(tb_uid_t), tsdbTbDataComp, SL_DISCARD_DUP_KEY, tsdbTbDataGetUid);
if (pMemTable->pSlIdx == NULL) { if (pMemTable->pSlIdx == NULL) {
pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA); pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA);
free(pMemTable); taosMemoryFree(pMemTable);
return NULL; return NULL;
} }
...@@ -55,7 +55,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { ...@@ -55,7 +55,7 @@ STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) {
if (pMemTable->pHashIdx == NULL) { if (pMemTable->pHashIdx == NULL) {
pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA); pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA);
tSkipListDestroy(pMemTable->pSlIdx); tSkipListDestroy(pMemTable->pSlIdx);
free(pMemTable); taosMemoryFree(pMemTable);
return NULL; return NULL;
} }
...@@ -69,7 +69,7 @@ void tsdbFreeMemTable(STsdb *pTsdb, STsdbMemTable *pMemTable) { ...@@ -69,7 +69,7 @@ void tsdbFreeMemTable(STsdb *pTsdb, STsdbMemTable *pMemTable) {
if (pMemTable->pMA) { if (pMemTable->pMA) {
pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA); pTsdb->pmaf->destroy(pTsdb->pmaf, pMemTable->pMA);
} }
free(pMemTable); taosMemoryFree(pMemTable);
} }
} }
...@@ -227,7 +227,35 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey ...@@ -227,7 +227,35 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
return 0; return 0;
} }
static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) { int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg) {
ASSERT(pMsg != NULL);
SSubmitMsgIter msgIter = {0};
SSubmitBlk *pBlock = NULL;
SSubmitBlkIter blkIter = {0};
STSRow *row = NULL;
terrno = TSDB_CODE_SUCCESS;
pMsg->length = htonl(pMsg->length);
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
while (true) {
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
if (pBlock == NULL) break;
pBlock->uid = htobe64(pBlock->uid);
pBlock->suid = htobe64(pBlock->suid);
pBlock->sversion = htonl(pBlock->sversion);
pBlock->dataLen = htonl(pBlock->dataLen);
pBlock->schemaLen = htonl(pBlock->schemaLen);
pBlock->numOfRows = htons(pBlock->numOfRows);
}
if (terrno != TSDB_CODE_SUCCESS) return -1;
return 0;
}
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
ASSERT(pMsg != NULL); ASSERT(pMsg != NULL);
// STsdbMeta * pMeta = pTsdb->tsdbMeta; // STsdbMeta * pMeta = pTsdb->tsdbMeta;
SSubmitMsgIter msgIter = {0}; SSubmitMsgIter msgIter = {0};
...@@ -376,7 +404,7 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p ...@@ -376,7 +404,7 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p
} }
static STbData *tsdbNewTbData(tb_uid_t uid) { static STbData *tsdbNewTbData(tb_uid_t uid) {
STbData *pTbData = (STbData *)calloc(1, sizeof(*pTbData)); STbData *pTbData = (STbData *)taosMemoryCalloc(1, sizeof(*pTbData));
if (pTbData == NULL) { if (pTbData == NULL) {
return NULL; return NULL;
} }
...@@ -397,14 +425,14 @@ static STbData *tsdbNewTbData(tb_uid_t uid) { ...@@ -397,14 +425,14 @@ static STbData *tsdbNewTbData(tb_uid_t uid) {
// tkeyComparFn, skipListCreateFlags, tsdbGetTsTupleKey); // tkeyComparFn, skipListCreateFlags, tsdbGetTsTupleKey);
// if (pTableData->pData == NULL) { // if (pTableData->pData == NULL) {
// terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; // terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
// free(pTableData); // taosMemoryFree(pTableData);
// return NULL; // return NULL;
// } // }
pTbData->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), tkeyComparFn, SL_DISCARD_DUP_KEY, pTbData->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), tkeyComparFn, SL_DISCARD_DUP_KEY,
tsdbGetTsTupleKey); tsdbGetTsTupleKey);
if (pTbData->pData == NULL) { if (pTbData->pData == NULL) {
free(pTbData); taosMemoryFree(pTbData);
return NULL; return NULL;
} }
...@@ -414,7 +442,7 @@ static STbData *tsdbNewTbData(tb_uid_t uid) { ...@@ -414,7 +442,7 @@ static STbData *tsdbNewTbData(tb_uid_t uid) {
static void tsdbFreeTbData(STbData *pTbData) { static void tsdbFreeTbData(STbData *pTbData) {
if (pTbData) { if (pTbData) {
tSkipListDestroy(pTbData->pData); tSkipListDestroy(pTbData->pData);
free(pTbData); taosMemoryFree(pTbData);
} }
} }
...@@ -582,7 +610,7 @@ int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot, SArray *pATab ...@@ -582,7 +610,7 @@ int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot, SArray *pATab
pSnapshot->mem = &(pSnapshot->mtable); pSnapshot->mem = &(pSnapshot->mtable);
pSnapshot->mem->tData = (STableData **)calloc(pSnapshot->omem->maxTables, sizeof(STableData *)); pSnapshot->mem->tData = (STableData **)taosMemoryCalloc(pSnapshot->omem->maxTables, sizeof(STableData *));
if (pSnapshot->mem->tData == NULL) { if (pSnapshot->mem->tData == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
taosRUnLockLatch(&(pSnapshot->omem->latch)); taosRUnLockLatch(&(pSnapshot->omem->latch));
...@@ -629,7 +657,7 @@ void tsdbUnTakeMemSnapShot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot) { ...@@ -629,7 +657,7 @@ void tsdbUnTakeMemSnapShot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot) {
tsdbFreeTableData(pTableData); tsdbFreeTableData(pTableData);
} }
} }
tfree(pSnapshot->mem->tData); taosMemoryFreeClear(pSnapshot->mem->tData);
tsdbUnRefMemTable(pRepo, pSnapshot->omem); tsdbUnRefMemTable(pRepo, pSnapshot->omem);
} }
...@@ -990,10 +1018,10 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, STSRow* ro ...@@ -990,10 +1018,10 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, STSRow* ro
TSDB_WLOCK_TABLE(pTable); TSDB_WLOCK_TABLE(pTable);
SDataCol *pDataCol = &(pLatestCols[idx]); SDataCol *pDataCol = &(pLatestCols[idx]);
if (pDataCol->pData == NULL) { if (pDataCol->pData == NULL) {
pDataCol->pData = malloc(pTCol->bytes); pDataCol->pData = taosMemoryMalloc(pTCol->bytes);
pDataCol->bytes = pTCol->bytes; pDataCol->bytes = pTCol->bytes;
} else if (pDataCol->bytes < pTCol->bytes) { } else if (pDataCol->bytes < pTCol->bytes) {
pDataCol->pData = realloc(pDataCol->pData, pTCol->bytes); pDataCol->pData = taosMemoryRealloc(pDataCol->pData, pTCol->bytes);
pDataCol->bytes = pTCol->bytes; pDataCol->bytes = pTCol->bytes;
} }
// the actual value size // the actual value size
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册