diff options
author | Guilherme Andrade <[email protected]> | 2017-04-22 17:22:32 +0100 |
---|---|---|
committer | Guilherme Andrade <[email protected]> | 2017-04-22 17:25:13 +0100 |
commit | 21e1d879faaae2278a68200fe1085d7e73791fa0 (patch) | |
tree | c711ec5ac1659532787af3c0f44b764426fc88e5 /erts/emulator/test/nif_SUITE_data | |
parent | d8756f8665a42effa2f3515369058cff4441abeb (diff) | |
download | otp-21e1d879faaae2278a68200fe1085d7e73791fa0.tar.gz otp-21e1d879faaae2278a68200fe1085d7e73791fa0.tar.bz2 otp-21e1d879faaae2278a68200fe1085d7e73791fa0.zip |
erts: Support custom salt in enif_hash
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c index 9d65b9c09b..2a80d48b62 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c +++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c @@ -689,7 +689,7 @@ static ERL_NIF_TERM compare(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) static ERL_NIF_TERM hash_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { - if (argc != 2) { + if (argc != 3) { return enif_make_badarg(env); } @@ -704,7 +704,12 @@ static ERL_NIF_TERM hash_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[] return enif_make_badarg(env); } - return enif_make_ulong(env, enif_hash(type, argv[1])); + unsigned long salt; + if (! enif_get_ulong(env, argv[2], &salt)) { + return enif_make_badarg(env); + } + + return enif_make_ulong(env, enif_hash(type, argv[1], salt)); } static ERL_NIF_TERM many_args_100(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) @@ -2884,7 +2889,7 @@ static ErlNifFunc nif_funcs[] = {"tuple_2_list", 1, tuple_2_list}, {"is_identical",2,is_identical}, {"compare",2,compare}, - {"hash_nif",2,hash_nif}, + {"hash_nif",3,hash_nif}, {"many_args_100", 100, many_args_100}, {"clone_bin", 1, clone_bin}, {"make_sub_bin", 3, make_sub_bin}, |