diff --git a/include/util/tencode.h b/include/util/tencode.h index a13afd44480eef8397befb42c2fe2a12c322b01e..e318d4f2400065c3a8926c06f36c7d077fb5b45a 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -477,22 +477,6 @@ static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) { return n; \ } while (0) -#define tGetV(p, v) \ - do { \ - int32_t n = 0; \ - if (v) *v = 0; \ - for (;;) { \ - if (p[n] <= 0x7f) { \ - if (v) (*v) |= (p[n] << (7 * n)); \ - n++; \ - break; \ - } \ - if (v) (*v) |= ((p[n] & 0x7f) << (7 * n)); \ - n++; \ - } \ - return n; \ - } while (0) - // PUT static FORCE_INLINE int32_t tPutU8(uint8_t* p, uint8_t v) { if (p) ((uint8_t*)p)[0] = v; @@ -607,7 +591,22 @@ static FORCE_INLINE int32_t tGetI64(uint8_t* p, int64_t* v) { return sizeof(int64_t); } -static FORCE_INLINE int32_t tGetU16v(uint8_t* p, uint16_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU16v(uint8_t* p, uint16_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint16_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint16_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI16v(uint8_t* p, int16_t* v) { int32_t n; @@ -619,7 +618,22 @@ static FORCE_INLINE int32_t tGetI16v(uint8_t* p, int16_t* v) { return n; } -static FORCE_INLINE int32_t tGetU32v(uint8_t* p, uint32_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU32v(uint8_t* p, uint32_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint32_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint32_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI32v(uint8_t* p, int32_t* v) { int32_t n; @@ -631,7 +645,22 @@ static FORCE_INLINE int32_t tGetI32v(uint8_t* p, int32_t* v) { return n; } -static FORCE_INLINE int32_t tGetU64v(uint8_t* p, uint64_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU64v(uint8_t* p, uint64_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint64_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint64_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI64v(uint8_t* p, int64_t* v) { int32_t n; diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index a331f88e61523003187850c47c593b28f94b817a..e96ee03b03f36c0e4d45c8ca8310441ff6d5a85b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -424,10 +424,12 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx, uint8_t **ppBuf) { ASSERT(n == size - sizeof(TSCKSUM)); + tFree(pBuf); return code; _err: tsdbError("vgId:%d read del idx failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); + tFree(pBuf); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index ed8bdc17a50d9f132a0b9651cc4143369e632b57..2e628edb7a2946521ed9f4aa5e4a4cdd173ee32a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -1016,7 +1016,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS SColData *pColData; SColVal *pColVal; - ASSERT(nColData > 0); + if (nColData == 0) goto _exit; tRowIterInit(pIter, pRow, pTSchema); pColData = tBlockDataGetColDataByIdx(pBlockData, iColData); @@ -1046,6 +1046,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS } } +_exit: pBlockData->nRow++; return code;