From f91124ef8edc8f2ae300270b46798a9885f7b81b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 20 Mar 2022 13:00:51 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/page/tdbPage.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/libs/tdb/src/page/tdbPage.c b/source/libs/tdb/src/page/tdbPage.c index b10cd7b0ec..9d679118e7 100644 --- a/source/libs/tdb/src/page/tdbPage.c +++ b/source/libs/tdb/src/page/tdbPage.c @@ -26,6 +26,7 @@ extern SPageMethods pageLargeMethods; static int tdbPageAllocate(SPage *pPage, int size, SCell **ppCell); static int tdbPageDefragment(SPage *pPage); +static int tdbPageFree(SPage *pPage, int idx, SCell *pCell, int szCell); int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg) { SPage *pPage; @@ -131,7 +132,25 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) { } int tdbPageDropCell(SPage *pPage, int idx) { - // TODO + int lidx; + SCell *pCell; + int szCell; + int nCells; + + nCells = TDB_PAGE_NCELLS(pPage); + + if (pPage->nOverflow == 0) { + lidx = idx; + } else { + // TODO + } + + pCell = TDB_PAGE_CELL_AT(pPage, lidx); + szCell = (*pPage->xCellSize)(pCell); + tdbPageFree(pPage, lidx, pCell, szCell); + + TDB_PAGE_NCELLS_SET(pPage, nCells - 1); + return 0; }