diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 0800ebbc49753a6f4c341c4feb608361b8d672e4..faced8e83993fd72292d7270e1427c156c40d40f 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -166,7 +166,7 @@ int tdbBtCursorInsert(SBTC *pBtc, const void *pKey, int kLen, const void *pVal, // TODO: refact code here pBt = pBtc->pBt; if (!pBt->pTmp) { - pBt->pTmp = (u8 *)malloc(pBt->pageSize); + pBt->pTmp = (u8 *)tdbOsMalloc(pBt->pageSize); if (pBt->pTmp == NULL) { return -1; } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index 1117550ed15b6d64449780542e7c2c6fb5d139e9..499116f0912f09d8508e17231ceb87c6ad49aed3 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -101,7 +101,7 @@ int tdbDbcOpen(STDB *pDb, STDBC **ppDbc) { STDBC *pDbc = NULL; *ppDbc = NULL; - pDbc = malloc(sizeof(*pDbc)); + pDbc = (STDBC *)tdbOsMalloc(sizeof(*pDbc)); if (pDbc == NULL) { return -1; } diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 5f79d60a78d22c971d8be85f880a32e25e930e92..f55f427b368e2c2385922852e80d4ec918d4cb90 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -222,7 +222,7 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) { ASSERT(memcmp(pPager->fid, pPage->pgid.fileid, TDB_FILE_ID_LEN) == 0); offset = (pPage->pgid.pgno - 1) * (i64)(pPager->pageSize); - ret = tdbPRead(pPager->fd, pPage->pData, pPager->pageSize, offset); + ret = tdbOsPRead(pPager->fd, pPage->pData, pPager->pageSize, offset); if (ret < 0) { // TODO: handle error return -1; diff --git a/source/libs/tdb/src/inc/tdbOs.h b/source/libs/tdb/src/inc/tdbOs.h index 0d7a3299f1e829c8ae34777a0b2fa86da2777cc8..ac538341f1a8ff4491e99e6cbfeef34d8bd3bb8b 100644 --- a/source/libs/tdb/src/inc/tdbOs.h +++ b/source/libs/tdb/src/inc/tdbOs.h @@ -49,9 +49,9 @@ typedef TdFilePtr tdb_fd_t; #else #define tdbOsOpen open #define tdbOsClose close -#define tdbOsRead read -#define tdbOsPRead pread -#define tdbOsWrite write +#define tdbOsRead read // TODO +#define tdbOsPRead pread // TODO +#define tdbOsWrite write // TODO #define tdbOsFSync fsync #endif @@ -65,7 +65,7 @@ typedef TdThreadSpinlock tdb_spinlock_t; #define tdbSpinlockDestroy taosThreadSpinDestroy #define tdbSpinlockLock taosThreadSpinLock #define tdbSpinlockUnlock taosThreadSpinUnlock -#define tdbSpinlockTrylock +#define tdbSpinlockTrylock pthread_spin_trylock // TODO // mutex lock typedef TdThreadMutex tdb_mutex_t; diff --git a/source/libs/tdb/src/page/tdbPage.c b/source/libs/tdb/src/page/tdbPage.c index 7f92f740da8ddb056fc1a45af3bb7f918a61089e..3301202a3383ef83b3426c7d4f27184095a05364 100644 --- a/source/libs/tdb/src/page/tdbPage.c +++ b/source/libs/tdb/src/page/tdbPage.c @@ -144,7 +144,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl } // TODO: here has memory leak - pNewCell = (SCell *)malloc(szCell); + pNewCell = (SCell *)tdbOsMalloc(szCell); memcpy(pNewCell, pCell, szCell); pPage->apOvfl[iOvfl] = pNewCell;