This commit is contained in:
Hongze Cheng 2022-02-23 09:02:46 +00:00
parent df0ab85f80
commit 79cdb9c275
4 changed files with 49 additions and 3 deletions

View File

@ -10,6 +10,9 @@ target_sources(tdb
"src/db/tdbPCache.c"
"src/db/tdbPFile.c"
"src/db/tdbUtil.c"
"src/db/tdbBtree.c"
"src/db/tdb.c"
"src/db/tdbEnv.c"
)
target_include_directories(

View File

@ -15,6 +15,7 @@
#include "tdbInt.h"
#if 0
struct STDb {
char dbname[TDB_MAX_DBNAME_LEN];
SBTree * pBt; // current access method (may extend)
@ -203,3 +204,4 @@ static int tdbDefaultKeyCmprFn(int keyLen1, const void *pKey1, int keyLen2, cons
}
return cret;
}
#endif

View File

@ -17,10 +17,51 @@
struct STEnv {
char * rootDir;
SPCache *pCache;
int jfd;
SPCache *pCache;
};
int tdbEnvOpen(const char *rootDir, STEnv **ppEnv) {
STEnv * pEnv;
int dsize;
int zsize;
uint8_t *pPtr;
*ppEnv = NULL;
dsize = strlen(rootDir);
zsize = sizeof(*pEnv) + dsize + 1;
pPtr = (uint8_t *)calloc(1, zsize);
if (pPtr == NULL) {
return -1;
}
pEnv = (STEnv *)pPtr;
pPtr += sizeof(*pEnv);
pEnv->rootDir = pPtr;
memcpy(pEnv->rootDir, rootDir, dsize);
pEnv->rootDir[dsize] = '\0';
*ppEnv = pEnv;
return 0;
}
int tdbEnvClose(STEnv *pEnv) {
// TODO
return 0;
}
int tdbEnvBegin(STEnv *pEnv) {
// TODO
return 0;
}
int tdbEnvCommit(STEnv *pEnv) {
// TODO
return 0;
}
#if 0
struct STDbEnv {
char * rootDir; // root directory of the environment

View File

@ -22,7 +22,7 @@ extern "C" {
typedef struct STEnv STEnv;
int tdbEnvOpen(STEnv **ppEnv);
int tdbEnvOpen(const char *rootDir, STEnv **ppEnv);
int tdbEnvClose(STEnv *pEnv);
int tdbEnvBegin(STEnv *pEnv);