mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 19:54:13 +08:00
mdbx: minor refine mdbx_env_create()
.
This commit is contained in:
parent
bec9312df5
commit
cf8540d84e
17
src/core.c
17
src/core.c
@ -11489,6 +11489,16 @@ lckless_stub(const MDBX_env *env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__cold int mdbx_env_create(MDBX_env **penv) {
|
__cold int mdbx_env_create(MDBX_env **penv) {
|
||||||
|
if (unlikely(!penv))
|
||||||
|
return MDBX_EINVAL;
|
||||||
|
*penv = nullptr;
|
||||||
|
|
||||||
|
const size_t os_psize = osal_syspagesize();
|
||||||
|
if (unlikely(!is_powerof2(os_psize) || os_psize < MIN_PAGESIZE)) {
|
||||||
|
ERROR("unsuitable system pagesize %" PRIuPTR, os_psize);
|
||||||
|
return MDBX_INCOMPATIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
MDBX_env *env = osal_calloc(1, sizeof(MDBX_env));
|
MDBX_env *env = osal_calloc(1, sizeof(MDBX_env));
|
||||||
if (unlikely(!env))
|
if (unlikely(!env))
|
||||||
return MDBX_ENOMEM;
|
return MDBX_ENOMEM;
|
||||||
@ -11516,12 +11526,6 @@ __cold int mdbx_env_create(MDBX_env **penv) {
|
|||||||
env->me_options.merge_threshold_16dot16_percent = 65536 / 4 /* 25% */;
|
env->me_options.merge_threshold_16dot16_percent = 65536 / 4 /* 25% */;
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
const size_t os_psize = osal_syspagesize();
|
|
||||||
if (unlikely(!is_powerof2(os_psize) || os_psize < MIN_PAGESIZE)) {
|
|
||||||
ERROR("unsuitable system pagesize %" PRIuPTR, os_psize);
|
|
||||||
rc = MDBX_INCOMPATIBLE;
|
|
||||||
goto bailout;
|
|
||||||
}
|
|
||||||
env->me_os_psize = (unsigned)os_psize;
|
env->me_os_psize = (unsigned)os_psize;
|
||||||
setup_pagesize(env, (env->me_os_psize < MAX_PAGESIZE) ? env->me_os_psize
|
setup_pagesize(env, (env->me_os_psize < MAX_PAGESIZE) ? env->me_os_psize
|
||||||
: MAX_PAGESIZE);
|
: MAX_PAGESIZE);
|
||||||
@ -11558,7 +11562,6 @@ __cold int mdbx_env_create(MDBX_env **penv) {
|
|||||||
|
|
||||||
bailout:
|
bailout:
|
||||||
osal_free(env);
|
osal_free(env);
|
||||||
*penv = nullptr;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user