From 933fbaffe8ccda4c4a21fea615730c216540ad28 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 15 Feb 2022 06:27:27 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbEnv.c | 2 +- source/libs/tdb/src/db/tdbPgCache.c | 10 +++++----- source/libs/tdb/src/inc/tdbPgCache.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 4057bd86e6..3e693e1753 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -68,7 +68,7 @@ int tdbEnvOpen(TENV *pEnv) { */ mkdir(pEnv->rootDir, 0755); - ret = pgCacheCreate(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize); + ret = pgCacheOpen(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize); if (ret != 0) { goto _err; } diff --git a/source/libs/tdb/src/db/tdbPgCache.c b/source/libs/tdb/src/db/tdbPgCache.c index 466a9b2eaf..0a222c152e 100644 --- a/source/libs/tdb/src/db/tdbPgCache.c +++ b/source/libs/tdb/src/db/tdbPgCache.c @@ -17,7 +17,7 @@ static void pgCachePinPage(SPage *pPage); static void pgCacheUnpinPage(SPage *pPage); -int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) { +int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) { SPgCache *pPgCache; SPage * pPage; @@ -38,7 +38,7 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) { pPgCache->pages = (SPage *)calloc(npage, sizeof(SPage)); if (pPgCache->pages == NULL) { - pgCacheDestroy(pPgCache); + pgCacheClose(pPgCache); return -1; } @@ -52,14 +52,14 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) { pPage->pData = (uint8_t *)calloc(1, pgSize); if (pPage->pData == NULL) { - pgCacheDestroy(pPgCache); + pgCacheClose(pPgCache); return -1; } pPgCache->pght.nbucket = npage; pPgCache->pght.buckets = (SPgList *)calloc(pPgCache->pght.nbucket, sizeof(SPgList)); if (pPgCache->pght.buckets == NULL) { - pgCacheDestroy(pPgCache); + pgCacheClose(pPgCache); return -1; } @@ -70,7 +70,7 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) { return 0; } -int pgCacheDestroy(SPgCache *pPgCache) { +int pgCacheClose(SPgCache *pPgCache) { SPage *pPage; if (pPgCache) { tfree(pPgCache->pght.buckets); diff --git a/source/libs/tdb/src/inc/tdbPgCache.h b/source/libs/tdb/src/inc/tdbPgCache.h index de9e254a92..d1a01903d5 100644 --- a/source/libs/tdb/src/inc/tdbPgCache.h +++ b/source/libs/tdb/src/inc/tdbPgCache.h @@ -24,8 +24,8 @@ typedef struct SPgCache SPgCache; typedef struct SPage SPage; // SPgCache -int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage); -int pgCacheDestroy(SPgCache *pPgCache); +int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage); +int pgCacheClose(SPgCache *pPgCache); SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid); int pgCacheRelease(SPage *pPage); -- GitLab