This commit is contained in:
Hongze Cheng 2022-03-16 02:32:46 +00:00
parent 9f9c7120bc
commit 07f6afe73e
1 changed files with 4 additions and 2 deletions

View File

@ -125,6 +125,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) {
int ret;
SCell *pTarget;
u8 *pTmp;
if (pPage->nOverflow || szCell + pPage->szOffset > pPage->nFree) {
// TODO: Page is full
@ -136,8 +137,9 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) {
}
memcpy(pTarget, pCell, szCell);
// TODO: memmove();
TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, pCell - pPage->pData);
pTmp = pPage->pCellIdx + idx + pPage->szOffset;
memmove(pTmp, pTmp + pPage->szOffset, pPage->pFreeStart - pTmp - pPage->szOffset);
TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, pTarget - pPage->pData);
TDB_PAGE_NCELLS_SET(pPage, TDB_PAGE_NCELLS(pPage) + 1);
}