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

more TDB

上级 8f6ba1fc
...@@ -166,7 +166,7 @@ int tdbBtCursorInsert(SBTC *pBtc, const void *pKey, int kLen, const void *pVal, ...@@ -166,7 +166,7 @@ int tdbBtCursorInsert(SBTC *pBtc, const void *pKey, int kLen, const void *pVal,
// TODO: refact code here // TODO: refact code here
pBt = pBtc->pBt; pBt = pBtc->pBt;
if (!pBt->pTmp) { if (!pBt->pTmp) {
pBt->pTmp = (u8 *)malloc(pBt->pageSize); pBt->pTmp = (u8 *)tdbOsMalloc(pBt->pageSize);
if (pBt->pTmp == NULL) { if (pBt->pTmp == NULL) {
return -1; return -1;
} }
......
...@@ -101,7 +101,7 @@ int tdbDbcOpen(STDB *pDb, STDBC **ppDbc) { ...@@ -101,7 +101,7 @@ int tdbDbcOpen(STDB *pDb, STDBC **ppDbc) {
STDBC *pDbc = NULL; STDBC *pDbc = NULL;
*ppDbc = NULL; *ppDbc = NULL;
pDbc = malloc(sizeof(*pDbc)); pDbc = (STDBC *)tdbOsMalloc(sizeof(*pDbc));
if (pDbc == NULL) { if (pDbc == NULL) {
return -1; return -1;
} }
......
...@@ -222,7 +222,7 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) { ...@@ -222,7 +222,7 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) {
ASSERT(memcmp(pPager->fid, pPage->pgid.fileid, TDB_FILE_ID_LEN) == 0); ASSERT(memcmp(pPager->fid, pPage->pgid.fileid, TDB_FILE_ID_LEN) == 0);
offset = (pPage->pgid.pgno - 1) * (i64)(pPager->pageSize); 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) { if (ret < 0) {
// TODO: handle error // TODO: handle error
return -1; return -1;
......
...@@ -49,9 +49,9 @@ typedef TdFilePtr tdb_fd_t; ...@@ -49,9 +49,9 @@ typedef TdFilePtr tdb_fd_t;
#else #else
#define tdbOsOpen open #define tdbOsOpen open
#define tdbOsClose close #define tdbOsClose close
#define tdbOsRead read #define tdbOsRead read // TODO
#define tdbOsPRead pread #define tdbOsPRead pread // TODO
#define tdbOsWrite write #define tdbOsWrite write // TODO
#define tdbOsFSync fsync #define tdbOsFSync fsync
#endif #endif
...@@ -65,7 +65,7 @@ typedef TdThreadSpinlock tdb_spinlock_t; ...@@ -65,7 +65,7 @@ typedef TdThreadSpinlock tdb_spinlock_t;
#define tdbSpinlockDestroy taosThreadSpinDestroy #define tdbSpinlockDestroy taosThreadSpinDestroy
#define tdbSpinlockLock taosThreadSpinLock #define tdbSpinlockLock taosThreadSpinLock
#define tdbSpinlockUnlock taosThreadSpinUnlock #define tdbSpinlockUnlock taosThreadSpinUnlock
#define tdbSpinlockTrylock #define tdbSpinlockTrylock pthread_spin_trylock // TODO
// mutex lock // mutex lock
typedef TdThreadMutex tdb_mutex_t; typedef TdThreadMutex tdb_mutex_t;
......
...@@ -144,7 +144,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl ...@@ -144,7 +144,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
} }
// TODO: here has memory leak // TODO: here has memory leak
pNewCell = (SCell *)malloc(szCell); pNewCell = (SCell *)tdbOsMalloc(szCell);
memcpy(pNewCell, pCell, szCell); memcpy(pNewCell, pCell, szCell);
pPage->apOvfl[iOvfl] = pNewCell; pPage->apOvfl[iOvfl] = pNewCell;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册