mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx: change mdbx_env_set_oomfunc() API.
This commit is contained in:
parent
132c9c994e
commit
2c43997026
6
mdbx.h
6
mdbx.h
@ -1452,8 +1452,10 @@ typedef int(MDBX_oom_func)(MDB_env *env, int pid, mdbx_tid_t tid, uint64_t txn,
|
||||
* a laggard readers to allowing reclaiming of freeDB.
|
||||
*
|
||||
* [in] env An environment handle returned by mdbx_env_create().
|
||||
* [in] oomfunc A MDBX_oom_func function or NULL to disable. */
|
||||
LIBMDBX_API void mdbx_env_set_oomfunc(MDB_env *env, MDBX_oom_func *oom_func);
|
||||
* [in] oomfunc A MDBX_oom_func function or NULL to disable.
|
||||
*
|
||||
* Returns A non-zero error value on failure and 0 on success. */
|
||||
LIBMDBX_API int mdbx_env_set_oomfunc(MDB_env *env, MDBX_oom_func *oom_func);
|
||||
|
||||
/* Get the current oom_func callback.
|
||||
*
|
||||
|
12
src/mdbx.c
12
src/mdbx.c
@ -9635,9 +9635,15 @@ int __cold mdbx_env_set_syncbytes(MDB_env *env, size_t bytes) {
|
||||
return env->me_map ? mdbx_env_sync(env, 0) : MDB_SUCCESS;
|
||||
}
|
||||
|
||||
void __cold mdbx_env_set_oomfunc(MDB_env *env, MDBX_oom_func *oomfunc) {
|
||||
if (likely(env && env->me_signature == MDBX_ME_SIGNATURE))
|
||||
env->me_oom_func = oomfunc;
|
||||
int __cold mdbx_env_set_oomfunc(MDB_env *env, MDBX_oom_func *oomfunc) {
|
||||
if (unlikely(!env))
|
||||
return MDBX_EINVAL;
|
||||
|
||||
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
|
||||
return MDBX_EBADSIGN;
|
||||
|
||||
env->me_oom_func = oomfunc;
|
||||
return MDB_SUCCESS;
|
||||
}
|
||||
|
||||
MDBX_oom_func *__cold mdbx_env_get_oomfunc(MDB_env *env) {
|
||||
|
Loading…
Reference in New Issue
Block a user