提交 a8882c5c 编写于 作者: H Hongze Cheng

more TDB

上级 8f6ba1fc
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册