This commit is contained in:
Hongze Cheng 2024-07-26 21:39:27 +08:00
parent 1709a98e78
commit 9cede6e2fe
2 changed files with 16 additions and 17 deletions

View File

@ -690,7 +690,6 @@ static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper
SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper)); SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper));
if (pDstWrapper == NULL) { if (pDstWrapper == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pDstWrapper->nCols = pSrcWrapper->nCols; pDstWrapper->nCols = pSrcWrapper->nCols;
@ -711,7 +710,7 @@ static FORCE_INLINE int32_t tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* p
assert(!pCmpr->pColCmpr); assert(!pCmpr->pColCmpr);
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr)); pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr));
if (pCmpr->pColCmpr == NULL) { if (pCmpr->pColCmpr == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
pCmpr->nCols = nCols; pCmpr->nCols = nCols;
return 0; return 0;
@ -722,7 +721,7 @@ static FORCE_INLINE int32_t tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr,
assert(!pCmpr->pColCmpr); assert(!pCmpr->pColCmpr);
pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr)); pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
if (pCmpr->pColCmpr == NULL) { if (pCmpr->pColCmpr == NULL) {
return terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (int32_t i = 0; i < pCmpr->nCols; i++) { for (int32_t i = 0; i < pCmpr->nCols; i++) {
SColCmpr* pColCmpr = &pCmpr->pColCmpr[i]; SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
@ -744,7 +743,6 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper)); SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
if (pSW == NULL) { if (pSW == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pSW->nCols = pSchemaWrapper->nCols; pSW->nCols = pSchemaWrapper->nCols;
@ -752,7 +750,6 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema)); pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
if (pSW->pSchema == NULL) { if (pSW->pSchema == NULL) {
taosMemoryFree(pSW); taosMemoryFree(pSW);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
@ -839,7 +836,6 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapp
if (pSW->nCols > 0) { if (pSW->nCols > 0) {
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema)); pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
if (pSW->pSchema == NULL) { if (pSW->pSchema == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
@ -2866,13 +2862,13 @@ static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeR
pReq->topicNames = taosArrayInit(topicNum, sizeof(void*)); pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
if (pReq->topicNames == NULL) { if (pReq->topicNames == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (int32_t i = 0; i < topicNum; i++) { for (int32_t i = 0; i < topicNum; i++) {
char* name = NULL; char* name = NULL;
buf = taosDecodeString(buf, &name); buf = taosDecodeString(buf, &name);
if (taosArrayPush(pReq->topicNames, &name) == NULL) { if (taosArrayPush(pReq->topicNames, &name) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
} }
@ -2894,13 +2890,11 @@ typedef struct {
static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) { static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo)); SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo));
if (pRebInfo == NULL) { if (pRebInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
tstrncpy(pRebInfo->key, key, TSDB_SUBSCRIBE_KEY_LEN); tstrncpy(pRebInfo->key, key, TSDB_SUBSCRIBE_KEY_LEN);
pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t)); pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t));
if (pRebInfo->removedConsumers == NULL) { if (pRebInfo->removedConsumers == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t)); pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
@ -3465,7 +3459,9 @@ static FORCE_INLINE void* taosDecodeSMqTopicInfoMsg(void* buf, SMqTopicInfo* pTo
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
SMqReportVgInfo vgInfo; SMqReportVgInfo vgInfo;
buf = taosDecodeSMqVgInfo(buf, &vgInfo); buf = taosDecodeSMqVgInfo(buf, &vgInfo);
taosArrayPush(pTopicInfo->pVgInfo, &vgInfo); if (taosArrayPush(pTopicInfo->pVgInfo, &vgInfo) == NULL) {
return NULL;
}
} }
return buf; return buf;
} }
@ -3501,7 +3497,9 @@ static FORCE_INLINE void* taosDecodeSMqReportMsg(void* buf, SMqReportReq* pMsg)
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
SMqTopicInfo topicInfo; SMqTopicInfo topicInfo;
buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo); buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo);
taosArrayPush(pMsg->pTopics, &topicInfo); if (taosArrayPush(pMsg->pTopics, &topicInfo) == NULL) {
return NULL;
}
} }
return buf; return buf;
} }
@ -3841,17 +3839,17 @@ int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy); int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy);
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) { static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
if (tEncodeI32(pEncoder, pReq->number) < 0) return -1; TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pReq->number));
for (int32_t i = 0; i < pReq->number; ++i) { for (int32_t i = 0; i < pReq->number; ++i) {
tEncodeTSma(pEncoder, pReq->tSma + i); TAOS_CHECK_RETURN(tEncodeTSma(pEncoder, pReq->tSma + i));
} }
return 0; return 0;
} }
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) { static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) {
if (tDecodeI32(pDecoder, &pReq->number) < 0) return -1; TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pReq->number));
for (int32_t i = 0; i < pReq->number; ++i) { for (int32_t i = 0; i < pReq->number; ++i) {
tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy); TAOS_CHECK_RETURN(tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy));
} }
return 0; return 0;
} }
@ -4069,7 +4067,6 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
buf = taosDecodeFixedI32(buf, &sz); buf = taosDecodeFixedI32(buf, &sz);
pRsp->topics = taosArrayInit(sz, sizeof(SMqSubTopicEp)); pRsp->topics = taosArrayInit(sz, sizeof(SMqSubTopicEp));
if (pRsp->topics == NULL) { if (pRsp->topics == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {

View File

@ -574,6 +574,7 @@ _exit:
} else { } else {
tlen = encoder.pos; tlen = encoder.pos;
} }
tEncoderClear(&encoder);
return tlen; return tlen;
} }
@ -691,6 +692,7 @@ _exit:
} else { } else {
tlen = encoder.pos; tlen = encoder.pos;
} }
tEncoderClear(&encoder);
return tlen; return tlen;
} }