diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 9454196d8ed417dee0ae5a7a3ba84ccab24420fd..0340bd3cd47b4677ad7bca02a2b056367f65922a 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -102,7 +102,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) pPage->szFreeCell = sizeof(SFreeCell); } else { pPage->szOffset = 3; - pPage->szPageHdr = sizeof(SLPageHdr); + pPage->szPageHdr = sizeof(SPageHdrL); pPage->szFreeCell = sizeof(SFreeCellL); } TDB_INIT_PAGE_LOCK(pPage); @@ -171,7 +171,7 @@ static int tdbPageAllocate(SPage *pPage, int size, SCell **ppCell) { int nxOffset; pCell = pPage->pData + TDB_PAGE_FCELL(pPage); - pOffset = TDB_IS_LARGE_PAGE(pPage) ? ((SLPageHdr *)(pPage->pPageHdr))[0].fCell + pOffset = TDB_IS_LARGE_PAGE(pPage) ? ((SPageHdrL *)(pPage->pPageHdr))[0].fCell : (u8 *)&(((SPageHdr *)(pPage->pPageHdr))[0].fCell); szCell = TDB_PAGE_FREE_CELL_SIZE(pPage, pCell); nxOffset = TDB_PAGE_FREE_CELL_NXOFFSET(pPage, pCell); diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index fe305f49fe131b6c1f92e33d71f70ee983aaf48b..9b904d7c6b87c3bb09cbe44ee132927a6802b6bc 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -38,7 +38,7 @@ typedef struct __attribute__((__packed__)) { u8 cCells[3]; u8 fCell[3]; u8 nFree[3]; -} SLPageHdr; +} SPageHdrL; // Page footer typedef struct __attribute__((__packed__)) { @@ -89,18 +89,18 @@ struct SPage { #define TDB_SPAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) TDB_SPAGE_CELL_OFFSET_AT(pPage, idx) = (OFFSET) /* For large page */ -#define TDB_LPAGE_FLAGS(pPage) (((SLPageHdr *)(pPage)->pPageHdr)->flags) -#define TDB_LPAGE_NCELLS(pPage) TDB_GET_U24(((SLPageHdr *)(pPage)->pPageHdr)->nCells) -#define TDB_LPAGE_CCELLS(pPage) TDB_GET_U24(((SLPageHdr *)(pPage)->pPageHdr)->cCells) -#define TDB_LPAGE_FCELL(pPage) TDB_GET_U24(((SLPageHdr *)(pPage)->pPageHdr)->fCell) -#define TDB_LPAGE_NFREE(pPage) TDB_GET_U24(((SLPageHdr *)(pPage)->pPageHdr)->nFree) +#define TDB_LPAGE_FLAGS(pPage) (((SPageHdrL *)(pPage)->pPageHdr)->flags) +#define TDB_LPAGE_NCELLS(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->nCells) +#define TDB_LPAGE_CCELLS(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->cCells) +#define TDB_LPAGE_FCELL(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->fCell) +#define TDB_LPAGE_NFREE(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->nFree) #define TDB_LPAGE_CELL_OFFSET_AT(pPage, idx) TDB_GET_U24((pPage)->aCellIdx + idx * 3) #define TDB_LPAGE_FLAGS_SET(pPage, FLAGS) TDB_LPAGE_FLAGS(pPage) = (flags) -#define TDB_LPAGE_NCELLS_SET(pPage, NCELLS) TDB_PUT_U24(((SLPageHdr *)(pPage)->pPageHdr)->nCells, NCELLS) -#define TDB_LPAGE_CCELLS_SET(pPage, CCELLS) TDB_PUT_U24(((SLPageHdr *)(pPage)->pPageHdr)->cCells, CCELLS) -#define TDB_LPAGE_FCELL_SET(pPage, FCELL) TDB_PUT_U24(((SLPageHdr *)(pPage)->pPageHdr)->fCell, FCELL) -#define TDB_LPAGE_NFREE_SET(pPage, NFREE) TDB_PUT_U24(((SLPageHdr *)(pPage)->pPageHdr)->nFree, NFREE) +#define TDB_LPAGE_NCELLS_SET(pPage, NCELLS) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->nCells, NCELLS) +#define TDB_LPAGE_CCELLS_SET(pPage, CCELLS) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->cCells, CCELLS) +#define TDB_LPAGE_FCELL_SET(pPage, FCELL) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->fCell, FCELL) +#define TDB_LPAGE_NFREE_SET(pPage, NFREE) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->nFree, NFREE) #define TDB_LPAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) TDB_PUT_U24((pPage)->aCellIdx + idx * 3, OFFSET) /* For page */