From 596c1933766c463ba2983e6957acf13fdb36dd40 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 28 Feb 2022 06:06:36 +0000 Subject: [PATCH] more --- source/libs/tdb/src/db/tdbEnv.c | 11 ++++++++++- source/libs/tdb/src/db/tdbPCache.c | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index d61ac704d7..3481472b33 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -17,6 +17,7 @@ struct STEnv { char * rootDir; + char * jfname; int jfd; SPCache *pCache; }; @@ -31,7 +32,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) *ppEnv = NULL; dsize = strlen(rootDir); - zsize = sizeof(*pEnv) + dsize + 1; + zsize = sizeof(*pEnv) + dsize * 2 + strlen(TDB_JOURNAL_NAME) + 3; pPtr = (uint8_t *)calloc(1, zsize); if (pPtr == NULL) { @@ -40,9 +41,17 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) pEnv = (STEnv *)pPtr; pPtr += sizeof(*pEnv); + // pEnv->rootDir pEnv->rootDir = pPtr; memcpy(pEnv->rootDir, rootDir, dsize); pEnv->rootDir[dsize] = '\0'; + pPtr = pPtr + dsize + 1; + // pEnv->jfname + pEnv->jfname = pPtr; + memcpy(pEnv->jfname, rootDir, dsize); + pEnv->jfname[dsize] = '/'; + memcpy(pEnv->jfname + dsize + 1, TDB_JOURNAL_NAME, strlen(TDB_JOURNAL_NAME)); + pEnv->jfname[dsize + 1 + strlen(TDB_JOURNAL_NAME)] = '\0'; pEnv->jfd = -1; diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 964e74619c..b3343bd170 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -68,6 +68,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) return -1; } + *ppCache = pCache; return 0; } -- GitLab