save one pointer indirection

This commit is contained in:
younes 2012-09-30 22:55:45 +02:00
parent 9485b349c0
commit 8c0593dd05
2 changed files with 9 additions and 8 deletions

View file

@ -13,7 +13,7 @@ But this module could also be used as a general key-value store to replace:
The following functions were implemented:
* `open/1`: equivalent to `emdb:open(DirName, 10485760)`.
* `open/1`: equivalent to `emdb:open(DirName, 10485760, 0)`.
* `open/2`: equivalent to `emdb:open(DirName, 10485760, 0)`.
* `open/3`: creates a new MDB database. This call also re-open an already existing one. Arguments are:
* DirName: database directory name
* MapSize: database map size (see [map.hrl](http://gitorious.org/mdb/mdb/blobs/master/libraries/libmdb/mdb.h))
@ -50,7 +50,8 @@ $ ./start.sh
9> none = Handle:get(<<"b">>).
%% delete a non-existing key <<"z">> 10> none = Handle:del(<<"z">>).
11> {ok, <<"1">>} = Handle:get(<<"a">>).
%% ensure key <<"a">>'s value is still <<"1">> 11> {ok, <<"1">>} = Handle:get(<<"a">>).
%% update the value for key <<"a">>
12> ok = Handle:update(<<"a">>, <<"7">>).

View file

@ -168,7 +168,7 @@ static ERL_NIF_TERM emdb_close_nif (ErlNifEnv * env,
HASH_DEL(emdb_map, node);
mdb_env_close(node -> env);
mdb_env_close(handle);
emdb_free(node);
return atom_ok;
@ -207,7 +207,7 @@ static ERL_NIF_TERM emdb_put_nif (ErlNifEnv * env,
if (! enif_inspect_iolist_as_binary(env, argv[2], &val))
return enif_make_badarg(env);
if (mdb_txn_begin(node -> env, NULL, 0, & txn))
if (mdb_txn_begin(handle, NULL, 0, & txn))
FAIL_FAST(EMDB_TXN_BEGIN_ERR, err2);
mkey.mv_size = key.size;
@ -265,7 +265,7 @@ static ERL_NIF_TERM emdb_get_nif (ErlNifEnv * env,
mkey.mv_size = key.size;
mkey.mv_data = key.data;
if (mdb_txn_begin(node -> env, NULL, 0, & txn))
if (mdb_txn_begin(handle, NULL, 0, & txn))
FAIL_FAST(EMDB_TXN_BEGIN_ERR, err1);
if(mdb_get(txn, node -> dbi, & mkey, & mdata))
@ -332,7 +332,7 @@ static ERL_NIF_TERM emdb_del_nif (ErlNifEnv * env,
mkey.mv_size = key.size;
mkey.mv_data = key.data;
if (mdb_txn_begin(node -> env, NULL, 0, & txn))
if (mdb_txn_begin(handle, NULL, 0, & txn))
FAIL_FAST(EMDB_TXN_BEGIN_ERR, err);
ret = mdb_del(txn, node -> dbi, & mkey, NULL);
@ -381,7 +381,7 @@ static ERL_NIF_TERM emdb_update_nif (ErlNifEnv * env,
if (! enif_inspect_iolist_as_binary(env, argv[2], &val))
return enif_make_badarg(env);
if (mdb_txn_begin(node -> env, NULL, 0, & txn))
if (mdb_txn_begin(handle, NULL, 0, & txn))
FAIL_FAST(EMDB_TXN_BEGIN_ERR, err2);
mkey.mv_size = key.size;
@ -423,7 +423,7 @@ static ERL_NIF_TERM emdb_drop_nif (ErlNifEnv * env,
if (NULL == node)
return enif_make_atom(env, EMDB_INVALID_HANDLE_ERR);
if (mdb_txn_begin(node -> env, NULL, 0, & txn))
if (mdb_txn_begin(handle, NULL, 0, & txn))
FAIL_FAST(EMDB_TXN_BEGIN_ERR, err2);
ret = mdb_drop(txn, node -> dbi, 0);