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

more TDB

上级 24bf28e2
......@@ -51,7 +51,18 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
}
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) {
// TODO
int ret;
SCell *pTarget;
if (pPage->nOverflow || szCell + TDB_PAGE_CELL_OFFSET_SIZE(pPage) > pPage->nFree) {
// TODO
} else {
ret = tdbPageAllocate(pPage, szCell, &pTarget);
if (ret < 0) {
return -1;
}
}
return 0;
}
......@@ -61,11 +72,29 @@ int tdbPageDropCell(SPage *pPage, int idx) {
}
static int tdbPageAllocate(SPage *pPage, int size, SCell **ppCell) {
// TODO
SCell *pCell;
int szOffset;
szOffset = TDB_PAGE_CELL_OFFSET_SIZE(pPage);
ASSERT(pPage->nFree > size + szOffset);
if (pPage->pFreeEnd - pPage->pFreeStart > size + szOffset) {
pPage->pFreeEnd -= size;
pPage->pFreeStart += szOffset;
pCell = pPage->pFreeEnd;
} else {
}
return 0;
}
static int tdbPageFree(SPage *pPage, int idx, SCell *pCell, int size) {
// TODO
return 0;
}
static int tdbPageDefragment(SPage *pPage) {
// TODO
return 0;
}
\ No newline at end of file
......@@ -44,8 +44,11 @@ struct SPage {
SPageHdr *pPageHdr;
SPageFtr *pPageFtr;
u16 *aCellIdx;
u8 *pFreeStart;
u8 *pFreeEnd;
int kLen;
int vLen;
int nFree;
int maxLocal;
int minLocal;
int nOverflow;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册