From 9a28e7d2b27abda8f7d456fd6f8447f41983252b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 14 Mar 2022 06:38:55 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbPage.c | 4 ++-- source/libs/tdb/src/inc/tdbPage.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 9454196d8e..0340bd3cd4 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 fe305f49fe..9b904d7c6b 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 */ -- GitLab