diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 4eb64785df..782b9a072d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -3641,7 +3641,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight); -void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); +int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); void tOffsetDestroy(void* pVal); typedef struct { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c5c0553abe..2fe6deaf14 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -9238,17 +9238,18 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { return false; } -void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { +int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { tOffsetDestroy(pLeft); *pLeft = *pRight; if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) { pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData); if (pLeft->primaryKey.pData == NULL) { uError("failed to allocate memory for offset"); - return; + return terrno; } (void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData); } + return 0; } void tOffsetDestroy(void *param) {