From 77af8e6b5d5ee3c9e67cb4a18cd9df294ae3c8a1 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 14 Mar 2022 03:02:21 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbPage.c | 7 +++++++ source/libs/tdb/src/inc/tdbPage.h | 1 + 2 files changed, 8 insertions(+) diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index ea12ccfc35..022c2f63f8 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -20,6 +20,11 @@ typedef struct __attribute__((__packed__)) { u16 nOffset; } SFreeCell; +typedef struct __attribute__((__packed__)) { + u8 size[3]; + u8 nOffset[3]; +} SFreeCellL; + static int tdbPageAllocate(SPage *pPage, int size, SCell **ppCell); static int tdbPageDefragment(SPage *pPage); @@ -46,9 +51,11 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) if (pageSize < 65536) { pPage->szOffset = 2; pPage->szPageHdr = sizeof(SPageHdr); + pPage->szFreeCell = sizeof(SFreeCell); } else { pPage->szOffset = 3; pPage->szPageHdr = sizeof(SLPageHdr); + pPage->szFreeCell = sizeof(SFreeCellL); } TDB_INIT_PAGE_LOCK(pPage); diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index 6c85ebd643..fe305f49fe 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -50,6 +50,7 @@ struct SPage { int pageSize; u8 szOffset; u8 szPageHdr; + u8 szFreeCell; pthread_spinlock_t lock; // Fields below used by pager and am u8 *pPageHdr;