From b23d2c7b6ec3c3e9a332390f52c426d82b38c682 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 28 Mar 2022 05:44:03 +0000 Subject: [PATCH] make TDB can compile --- source/libs/tdb/src/db/tdbOs.c | 2 +- source/libs/tdb/src/inc/tdbOs.h | 4 ++-- source/libs/tdb/test/tdbTest.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/libs/tdb/src/db/tdbOs.c b/source/libs/tdb/src/db/tdbOs.c index e52f788da9..5ca3578985 100644 --- a/source/libs/tdb/src/db/tdbOs.c +++ b/source/libs/tdb/src/db/tdbOs.c @@ -72,7 +72,7 @@ i64 tdbOsPRead(tdb_fd_t fd, void *pData, i64 nBytes, i64 offset) { } // tdbOsWrite -i64 taosWriteFile(tdb_fd_t fd, const void *pData, i64 nBytes) { +i64 tdbOsWrite(tdb_fd_t fd, const void *pData, i64 nBytes) { i64 nWrite = 0; i64 iWrite = 0; u8 *pBuf = (u8 *)pData; diff --git a/source/libs/tdb/src/inc/tdbOs.h b/source/libs/tdb/src/inc/tdbOs.h index b8ae85ea65..751c105913 100644 --- a/source/libs/tdb/src/inc/tdbOs.h +++ b/source/libs/tdb/src/inc/tdbOs.h @@ -21,7 +21,7 @@ extern "C" { #endif // TODO: use cmake to control the option -// #define TDB_FOR_TDENGINE +#define TDB_FOR_TDENGINE // For memory ----------------- #ifdef TDB_FOR_TDENGINE @@ -69,7 +69,7 @@ typedef int tdb_fd_t; i64 tdbOsRead(tdb_fd_t fd, void *pData, i64 nBytes); i64 tdbOsPRead(tdb_fd_t fd, void *pData, i64 nBytes, i64 offset); -i64 taosWriteFile(tdb_fd_t fd, const void *pData, i64 nBytes); +i64 tdbOsWrite(tdb_fd_t fd, const void *pData, i64 nBytes); #define tdbOsFSync fsync #define tdbOsLSeek lseek diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp index 6889e33902..e8c6477de0 100644 --- a/source/libs/tdb/test/tdbTest.cpp +++ b/source/libs/tdb/test/tdbTest.cpp @@ -11,7 +11,7 @@ typedef struct SPoolMem { } SPoolMem; static SPoolMem *openPool() { - SPoolMem *pPool = (SPoolMem *)malloc(sizeof(*pPool)); + SPoolMem *pPool = (SPoolMem *)tdbOsMalloc(sizeof(*pPool)); pPool->prev = pPool->next = pPool; pPool->size = 0; @@ -31,12 +31,12 @@ static void closePool(SPoolMem *pPool) { pMem->prev->next = pMem->next; pPool->size -= pMem->size; - free(pMem); + tdbOsFree(pMem); } while (1); assert(pPool->size == 0); - free(pPool); + tdbOsFree(pPool); } #define clearPool closePool @@ -46,7 +46,7 @@ static void *poolMalloc(void *arg, int size) { SPoolMem *pPool = (SPoolMem *)arg; SPoolMem *pMem; - pMem = (SPoolMem *)malloc(sizeof(*pMem) + size); + pMem = (SPoolMem *)tdbOsMalloc(sizeof(*pMem) + size); if (pMem == NULL) { assert(0); } @@ -73,7 +73,7 @@ static void poolFree(void *arg, void *ptr) { pMem->prev->next = pMem->next; pPool->size -= pMem->size; - free(pMem); + tdbOsFree(pMem); } static int tKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) { -- GitLab