From eaca069a45b8b9ff4b98245f91a58edfeca5d16c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 2 Jan 2022 10:34:31 +0000 Subject: [PATCH] more --- include/util/encode.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/util/encode.h b/include/util/encode.h index f5c8db0b5a..02edbe888e 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -125,6 +125,7 @@ static int tDecodeDouble(SCoder* pDecoder, double* val); static int tDecodeBinary(SCoder* pDecoder, const void** val, uint64_t* len); static int tDecodeCStrAndLen(SCoder* pDecoder, const char** val, uint64_t* len); static int tDecodeCStr(SCoder* pDecoder, const char** val); +static int tDecodeCStrTo(SCoder* pDecoder, char* val); /* ------------------------ IMPL ------------------------ */ #define TD_ENCODE_MACRO(CODER, VAL, TYPE, BITS) \ @@ -385,6 +386,15 @@ static FORCE_INLINE int tDecodeCStr(SCoder* pDecoder, const char** val) { return tDecodeCStrAndLen(pDecoder, val, &len); } +static int tDecodeCStrTo(SCoder* pDecoder, char* val) { + const char* pStr; + uint64_t len; + if (tDecodeCStrAndLen(pDecoder, &pStr, &len) < 0) return -1; + + memcpy(val, pStr, len+1); + return 0; +} + #ifdef __cplusplus } #endif