diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 575a0e6274691d3b24429a891979507a36eed543..f87f660ab350eb64ea272ef085e8c14ccfe56eae 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -212,6 +212,11 @@ if(${BUILD_WITH_UV}) MESSAGE("Windows need set no-sign-compare") add_compile_options(-Wno-sign-compare) endif () + if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + file(READ "libuv/include/uv.h" CONTENTS) + string(REGEX REPLACE "/([\r]*)\nstruct uv_tcp_s {" "/\\1\ntypedef BOOL (PASCAL *LPFN_CONNECTEX) (SOCKET s, const struct sockaddr* name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength,LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped);\\1\nstruct uv_tcp_s {" CONTENTS_NEW "${CONTENTS}") + file(WRITE "libuv/include/uv.h" "${CONTENTS_NEW}") + endif () add_subdirectory(libuv) endif(${BUILD_WITH_UV}) @@ -243,6 +248,10 @@ if(${BUILD_WITH_SQLITE}) endif(${BUILD_WITH_SQLITE}) # pthread +if(${BUILD_PTHREAD}) + ADD_DEFINITIONS("-DPTW32_STATIC_LIB") + add_subdirectory(pthread-win32) +endif(${BUILD_PTHREAD}) # ================================================================================================ diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 8871bae4e9012e0bb0af1dcf4081879948bdb734..1d89b075395c89e42475cacf94867842dec058f5 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -69,7 +69,7 @@ typedef struct SProjectLogicNode { } SProjectLogicNode; typedef struct SVnodeModifLogicNode { - SLogicNode node;; + SLogicNode node; int32_t msgType; SArray* pDataBlocks; SVgDataBlocks* pVgDataBlocks; @@ -124,7 +124,7 @@ typedef struct SSubLogicPlan { } SSubLogicPlan; typedef struct SQueryLogicPlan { - ENodeType type;; + ENodeType type; int32_t totalLevel; SNodeList* pTopSubplans; } SQueryLogicPlan; @@ -252,7 +252,7 @@ typedef struct SSubplan { } SSubplan; typedef struct SQueryPlan { - ENodeType type;; + ENodeType type; uint64_t queryId; int32_t numOfSubplans; SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0. diff --git a/include/os/os.h b/include/os/os.h index 12f4e733c22a2418af2b4ad80a692ab6c8f7e803..9118a92e11beff1c0403616632be4ff4c5493195 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -25,10 +25,11 @@ extern "C" { #include #include +#include + #if !defined(WINDOWS) #include #include -#include #include #include #include @@ -36,6 +37,12 @@ extern "C" { #include #include #include +#include +#include +#include +#include +#include +#include #if defined(DARWIN) #else @@ -61,12 +68,7 @@ extern "C" { #include #include #include -#include -#include -#include -#include #include -#include #include diff --git a/include/os/osDef.h b/include/os/osDef.h index fcc96c19b46eb51da82ea5fcc0d87b7a4b90d742..492df1047c75ee43010f9a10712d05668d598624 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -56,6 +56,7 @@ extern "C" { // specific typedef int (*__compar_fn_t)(const void *, const void *); #define ssize_t int + #define _SSIZE_T_ #define bzero(ptr, size) memset((ptr), 0, (size)) #define strcasecmp _stricmp #define strncasecmp _strnicmp diff --git a/include/os/osFile.h b/include/os/osFile.h index 58a9df25042638c72d84f79ae57873f87b173249..209cecedf8946ae51da4cebdbd98dd73a017aedf 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -24,7 +24,7 @@ extern "C" { #if defined(WINDOWS) typedef int32_t FileFd; -typedef SOCKET SocketFd; +typedef int32_t SocketFd; #else typedef int32_t FileFd; typedef int32_t SocketFd; diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 520d3af3313131ef7a7e8936a0de963374a3ff26..fb330a9e2fc62cc90f9047ace4488a954a51f50b 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -25,6 +25,8 @@ #define epoll_create EPOLL_CREATE_FUNC_TAOS_FORBID #define epoll_ctl EPOLL_CTL_FUNC_TAOS_FORBID #define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID + #define inet_addr INET_ADDR_FUNC_TAOS_FORBID + #define inet_ntoa INET_NTOA_FUNC_TAOS_FORBID #endif #if defined(WINDOWS) diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 7777466973e414ed4aa12f77e865585023a0fd2f..e1cc6f78299f9638583f277cd99ad94b640661d4 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -16,7 +16,6 @@ #ifndef _TD_OS_SYSINFO_H_ #define _TD_OS_SYSINFO_H_ -#include #include "os.h" #ifdef __cplusplus diff --git a/include/util/tencode.h b/include/util/tencode.h index cbbd55c8a3216e4b580bf724518a11ed368635e6..7e1b624dfb5095536a8c5f170b80af38afc68d52 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -75,7 +75,7 @@ typedef struct { #define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos) #define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE)) #define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE)) -#define TCODER_MALLOC(SIZE, CODER) TFL_MALLOC(SIZE, &((CODER)->fl)) +#define TCODER_MALLOC(PTR, TYPE, SIZE, CODER) TFL_MALLOC(PTR, TYPE, SIZE, &((CODER)->fl)) void tCoderInit(SCoder* pCoder, td_endian_t endian, uint8_t* data, int32_t size, td_coder_t type); void tCoderClear(SCoder* pCoder); diff --git a/include/util/tfreelist.h b/include/util/tfreelist.h index c1913ebaf95866218db3d6b151a903f040e2175e..0a507aeec9b35951e7e646559cf058d5cb05b69a 100644 --- a/include/util/tfreelist.h +++ b/include/util/tfreelist.h @@ -29,15 +29,17 @@ struct SFreeListNode { typedef TD_SLIST(SFreeListNode) SFreeList; -#define TFL_MALLOC(SIZE, LIST) \ - ({ \ +#define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \ + do { \ void *ptr = malloc((SIZE) + sizeof(struct SFreeListNode)); \ if (ptr) { \ TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \ ptr = ((struct SFreeListNode *)ptr)->payload; \ + (PTR) = (TYPE)(ptr); \ + }else{ \ + (PTR) = NULL; \ } \ - ptr; \ - }) + }while(0); #define tFreeListInit(pFL) TD_SLIST_INIT(pFL) diff --git a/include/util/types.h b/include/util/types.h index f7a535c965fd6deac8dc2eb1d486c072a0e867e6..981c457fc10598d7109c44845939364c428f7a66 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -82,7 +82,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 #define VARSTR_HEADER_SIZE sizeof(VarDataLenT) #define varDataLen(v) ((VarDataLenT *)(v))[0] -#define varDataVal(v) ((void *)((char *)v + VARSTR_HEADER_SIZE)) +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) typedef int32_t VarDataOffsetT; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 794e5a85426f68c6d564b62aed987bcd90aebc03..d9242cf0ac68b65c264d2c74028f9a513eb7f3c6 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2467,7 +2467,7 @@ int32_t tEncodeSMqCMCommitOffsetReq(SCoder *encoder, const SMqCMCommitOffsetReq int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq) { if (tStartDecode(decoder) < 0) return -1; if (tDecodeI32(decoder, &pReq->num) < 0) return -1; - pReq->offsets = TCODER_MALLOC(pReq->num * sizeof(SMqOffset), decoder); + TCODER_MALLOC(pReq->offsets, SMqOffset*, pReq->num * sizeof(SMqOffset), decoder); if (pReq->offsets == NULL) return -1; for (int32_t i = 0; i < pReq->num; i++) { tDecodeSMqOffset(decoder, &pReq->offsets[i]); diff --git a/source/common/src/tname.c b/source/common/src/tname.c index a97792de663ae25600ae07a9c01f7bea19888eaa..370bf0396999d25a2ef019088a4c90ec3e7e3485 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -217,7 +217,7 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name } int32_t tNameSetAcctId(SName* dst, int32_t acctId) { - assert(dst != NULL && acct != NULL); + assert(dst != NULL); dst->acctId = acctId; return 0; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 5a5e1d46c622ec9d854614b9ddb4724bd047e710..1d0cbf22df0e245776ec7b1128a09fb0eb2364fd 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -89,7 +89,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pSubplan->id.groupId = pCxt->groupId; pSubplan->subplanType = SUBPLAN_TYPE_SCAN; pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan); - TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList, SVgroupsInfo); + TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList, SVgroupsInfo*); SPLIT_FLAG_SET_MASK(pSubplan->splitFlag, SPLIT_FLAG_STS); return pSubplan; } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 90889a7af0e5585a808ea34afe4ff365e1b2341b..9486405331bd3d5352eb8b1ce73cbff950b3feaa 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -14,15 +14,12 @@ */ #include "syncUtil.h" -#include -#include -#include #include "syncEnv.h" // ---- encode / decode uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint64_t u64; - uint32_t hostU32 = (uint32_t)inet_addr(host); + uint32_t hostU32 = (uint32_t)taosInetAddr(host); // assert(hostU32 != (uint32_t)-1); u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); return u64; @@ -33,7 +30,7 @@ void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port) { struct in_addr addr; addr.s_addr = hostU32; - snprintf(host, len, "%s", inet_ntoa(addr)); + snprintf(host, len, "%s", taosInetNtoa(addr)); *port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16); } diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 86e7980733f39baa393cc45d87cedf755593900e..a2520babe5575bdbc157a91f7b20c48c4c9ba0de 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -27,7 +27,8 @@ typedef struct { } SBtIdx; // Btree page header definition -typedef struct __attribute__((__packed__)) { +#pragma pack (push,1) +typedef struct { uint8_t flag; // page flag int32_t vlen; // value length of current page, TDB_VARIANT_LEN for variant length uint16_t nPayloads; // number of total payloads @@ -36,6 +37,7 @@ typedef struct __attribute__((__packed__)) { pgoff_t offPayload; // payload offset pgno_t rChildPgno; // right most child page number } SBtPgHdr; +#pragma pack(pop) typedef int (*BtreeCmprFn)(const void *, const void *); diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index a415d6d60e500cae4389aaf79fdc18f60cae4349..30e8fab03902e39c9f2c1c88756518693bf2baf6 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -30,11 +30,7 @@ struct STDbEnv { } pgfht; // page file hash table; }; -#define TDB_ENV_PGF_HASH(fileid) \ - ({ \ - uint8_t *tmp = (uint8_t *)(fileid); \ - tmp[0] + tmp[1] + tmp[2]; \ - }) +#define TDB_ENV_PGF_HASH(fileid) (((uint8_t *)(fileid))[0] + ((uint8_t *)(fileid))[1] + ((uint8_t *)(fileid))[2]) static int tdbEnvDestroy(TENV *pEnv); diff --git a/source/libs/tdb/src/db/tdbPgCache.c b/source/libs/tdb/src/db/tdbPgCache.c index 1b000aa6d6f85dd983b0d60a3c2565990cfd815e..ef3f79410a8e03d1b0fa94eb1a555fdb7baac397 100644 --- a/source/libs/tdb/src/db/tdbPgCache.c +++ b/source/libs/tdb/src/db/tdbPgCache.c @@ -106,11 +106,7 @@ int pgCacheClose(SPgCache *pPgCache) { return 0; } -#define PG_CACHE_HASH(fileid, pgno) \ - ({ \ - uint64_t *tmp = (uint64_t *)(fileid); \ - (tmp[0] + tmp[1] + tmp[2] + (pgno)); \ - }) +#define PG_CACHE_HASH(fileid, pgno) (((uint64_t *)(fileid))[0] + ((uint64_t *)(fileid))[1] + ((uint64_t *)(fileid))[2] + (pgno)) SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid) { SPage * pPage; diff --git a/source/libs/tdb/src/inc/tdbPgFile.h b/source/libs/tdb/src/inc/tdbPgFile.h index eaeebf6b9d3d6260b181b0e8fd9607a2befe7482..0a8c277479e6b49e6a1bbf1854ca8c7f6f509306 100644 --- a/source/libs/tdb/src/inc/tdbPgFile.h +++ b/source/libs/tdb/src/inc/tdbPgFile.h @@ -20,13 +20,15 @@ extern "C" { #endif -typedef struct __attribute__((__packed__)) { +#pragma pack (push,1) +typedef struct { char hdrInfo[16]; // info string pgsz_t szPage; // page size of current file int32_t cno; // commit number counter pgno_t freePgno; // freelist page number uint8_t resv[100]; // reserved space } SPgFileHdr; +#pragma pack(pop) #define TDB_PG_FILE_HDR_SIZE 128 diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 31097a591fe8bc97b0b98775cc1753c28d3c9b3e..df35b8d67b2e2b0c91c154c4ff3d7cb951d0d8b1 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -207,8 +207,8 @@ void cliHandleResp(SCliConn* conn) { } tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn, - TMSG_INFO(pHead->msgType), inet_ntoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), - inet_ntoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); + TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), + taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); conn->secured = pHead->secured; @@ -519,8 +519,8 @@ void cliSend(SCliConn* pConn) { uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn, - TMSG_INFO(pHead->msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); pConn->writeReq.data = pConn; uv_write(&pConn->writeReq, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb); diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 2efdb109aae693ddd074de8a02de4d8477e1ca6a..73d836319fcabd96fc42790b391fb39d8a6a154d 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -202,7 +202,7 @@ static void uvHandleReq(SSrvConn* pConn) { STransMsgHead* pHead = (STransMsgHead*)p->msg; if (pHead->secured == 1) { - STransUserMsg* uMsg = (p->msg + p->msgLen - sizeof(STransUserMsg)); + STransUserMsg* uMsg = (STransUserMsg*)((char*)p->msg + p->msgLen - sizeof(STransUserMsg)); memcpy(pConn->user, uMsg->user, tListLen(uMsg->user)); memcpy(pConn->secret, uMsg->secret, tListLen(uMsg->secret)); } @@ -235,12 +235,12 @@ static void uvHandleReq(SSrvConn* pConn) { transRefSrvHandle(pConn); transMsg.handle = pConn; tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), - inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); } else { tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, no resp ", pConn, - TMSG_INFO(transMsg.msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); + TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); } STrans* pTransInst = (STrans*)p->shandle; @@ -347,7 +347,7 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) { // impl later } tDebug("server conn %p %s is sent to %s:%d, local info: %s:%d", pConn, TMSG_INFO(pHead->msgType), - inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); pHead->msgLen = htonl(len); @@ -374,8 +374,8 @@ static void uvStartSendResp(SSrvMsg* smsg) { transUnrefSrvHandle(pConn); if (taosArrayGetSize(pConn->srvMsgs) > 0) { - tDebug("server conn %p push data to client %s:%d, local info: %s:%d", pConn, inet_ntoa(pConn->addr.sin_addr), - ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + tDebug("server conn %p push data to client %s:%d, local info: %s:%d", pConn, taosInetNtoa(pConn->addr.sin_addr), + ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); taosArrayPush(pConn->srvMsgs, &smsg); return; } diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 248f758787d277f0b319d6e89f09a1fde925b80f..70ec7e06557d75358f2b4e33a8aec06b493e06d2 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -19,9 +19,6 @@ #include "tref.h" #include "walInt.h" -#include -#include - int64_t inline walGetFirstVer(SWal* pWal) { return pWal->vers.firstVer; } int64_t inline walGetSnaphostVer(SWal* pWal) { return pWal->vers.snapshotVer; } diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index 27906c262753f2bf02bd9cd09b4ca9227ba26bba..ed240015d4dcbff2ddb0c44cbeee7fc751f95429 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -3,9 +3,10 @@ add_library(os STATIC ${OS_SRC}) target_include_directories( os PUBLIC "${CMAKE_SOURCE_DIR}/include/os" - PRIVATE "${CMAKE_SOURCE_DIR}/include" - PRIVATE "${CMAKE_SOURCE_DIR}/include/util" - PRIVATE "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" + PUBLIC "${CMAKE_SOURCE_DIR}/include" + PUBLIC "${CMAKE_SOURCE_DIR}/include/util" + PUBLIC "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" + PUBLIC "${CMAKE_SOURCE_DIR}/contrib/gnuregex" ) target_link_libraries( os pthread dl rt m diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 062d144933136891acc98b4ba07b43d09c8a9f69..5e3cf1247c6941064a336cb14c5f51c2c6e4013e 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -427,7 +427,7 @@ int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); + int32_t ret = WCSPatternMatch(pattern, (const wchar_t *)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); free(pattern); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; diff --git a/source/util/test/encodeTest.cpp b/source/util/test/encodeTest.cpp index 25314842fb4d417b29dca127a1da70d55b87bd4f..b4da43dfb72600dbcc6ea5fda1fdde220e99c803 100644 --- a/source/util/test/encodeTest.cpp +++ b/source/util/test/encodeTest.cpp @@ -230,7 +230,7 @@ static int32_t tSStructA_v1_decode(SCoder *pCoder, SStructA_v1 *pSAV1) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV1->A_c = (char *)TCODER_MALLOC(len + 1, pCoder); + TCODER_MALLOC(pSAV1->A_c, char*, len + 1, pCoder); memcpy(pSAV1->A_c, tstr, len + 1); tEndDecode(pCoder); @@ -269,7 +269,7 @@ static int32_t tSStructA_v2_decode(SCoder *pCoder, SStructA_v2 *pSAV2) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV2->A_c = (char *)TCODER_MALLOC(len + 1, pCoder); + TCODER_MALLOC(pSAV2->A_c, char*, len + 1, pCoder); memcpy(pSAV2->A_c, tstr, len + 1); // ------------------------NEW FIELDS DECODE------------------------------- @@ -305,7 +305,7 @@ static int32_t tSFinalReq_v1_encode(SCoder *pCoder, const SFinalReq_v1 *ps1) { static int32_t tSFinalReq_v1_decode(SCoder *pCoder, SFinalReq_v1 *ps1) { if (tStartDecode(pCoder) < 0) return -1; - ps1->pA = (SStructA_v1 *)TCODER_MALLOC(sizeof(*(ps1->pA)), pCoder); + TCODER_MALLOC(ps1->pA, SStructA_v1*, sizeof(*(ps1->pA)), pCoder); if (tSStructA_v1_decode(pCoder, ps1->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps1->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps1->v_b) < 0) return -1; @@ -339,7 +339,7 @@ static int32_t tSFinalReq_v2_encode(SCoder *pCoder, const SFinalReq_v2 *ps2) { static int32_t tSFinalReq_v2_decode(SCoder *pCoder, SFinalReq_v2 *ps2) { if (tStartDecode(pCoder) < 0) return -1; - ps2->pA = (SStructA_v2 *)TCODER_MALLOC(sizeof(*(ps2->pA)), pCoder); + TCODER_MALLOC(ps2->pA, SStructA_v2*, sizeof(*(ps2->pA)), pCoder); if (tSStructA_v2_decode(pCoder, ps2->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps2->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps2->v_b) < 0) return -1; diff --git a/source/util/test/freelistTest.cpp b/source/util/test/freelistTest.cpp index 7fd3d693fb6ccd3cae2a0a916b3c0aaa7dc6d071..440e997042a4b7f3395f32d5b0eccfe2960a5c0f 100644 --- a/source/util/test/freelistTest.cpp +++ b/source/util/test/freelistTest.cpp @@ -8,7 +8,8 @@ TEST(TD_UTIL_FREELIST_TEST, simple_test) { tFreeListInit(&fl); for (size_t i = 0; i < 1000; i++) { - void *ptr = TFL_MALLOC(1024, &fl); + void *ptr = NULL; + TFL_MALLOC(ptr, void*, 1024, &fl); GTEST_ASSERT_NE(ptr, nullptr); }