From d566ac92c6e388dcd27ce88801b7390c3448e929 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 23 Dec 2022 18:09:59 +0800 Subject: [PATCH] fix(util): replace with new ASSERTS --- source/util/src/talgo.c | 2 +- source/util/src/tbuffer.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 057d3a620c..d9319485b7 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -39,7 +39,7 @@ static void median(void *src, int64_t size, int64_t s, int64_t e, const void *pa doswap(elePtrAt(src, size, s), elePtrAt(src, size, e), size, buf); } - assert(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && + ASSERT(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) <= 0); #ifdef _DEBUG_VIEW diff --git a/source/util/src/tbuffer.c b/source/util/src/tbuffer.c index d2fac72c77..5a7e89f7cd 100644 --- a/source/util/src/tbuffer.c +++ b/source/util/src/tbuffer.c @@ -54,7 +54,7 @@ const char* tbufRead(SBufferReader* buf, size_t size) { } void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size) { - assert(dst != NULL); + ASSERT(dst != NULL); // always using memcpy, leave optimization to compiler memcpy(dst, tbufRead(buf, size), size); } @@ -103,7 +103,7 @@ const char* tbufReadBinary(SBufferReader* buf, size_t* len) { } size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size) { - assert(dst != NULL); + ASSERTS(dst != NULL, "dst != NULL"); size_t len; const char* data = tbufReadBinary(buf, &len); if (len >= size) { @@ -252,17 +252,17 @@ char* tbufGetData(SBufferWriter* buf, bool takeOver) { } void tbufWrite(SBufferWriter* buf, const void* data, size_t size) { - assert(data != NULL); + ASSERTS(data != NULL, "data != NULL"); tbufEnsureCapacity(buf, size); memcpy(buf->data + buf->pos, data, size); buf->pos += size; } void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size) { - assert(data != NULL); + ASSERTS(data != NULL, "data != NULL"); // this function can only be called to fill the gap on previous writes, // so 'pos + size <= buf->pos' must be true - assert(pos + size <= buf->pos); + ASSERTS(pos + size <= buf->pos, "pos + size <= buf->pos"); memcpy(buf->data + pos, data, size); } @@ -270,7 +270,7 @@ static void tbufWriteLength(SBufferWriter* buf, size_t len) { // maximum length is 65535, if larger length is required // this function and the corresponding read function need to be // revised. - assert(len <= 0xffff); + ASSERTS(len <= 0xffff, "len <= 0xffff"); tbufWriteUint16(buf, (uint16_t)len); } -- GitLab