diff options
author | Sverker Eriksson <[email protected]> | 2011-11-09 18:49:25 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2011-11-09 18:49:25 +0100 |
commit | d82c450402b4fe030befc28cc77e3bc2c07001c1 (patch) | |
tree | d35ff6c3ddcc94a2356504db7fd585a046afe8a5 /erts/emulator/test/nif_SUITE_data/nif_SUITE.c | |
parent | 12a5e61df498ec80383514ca79b795c40522e19a (diff) | |
parent | bf2b0f7fbea5cbe0e90021a930fa71570f4b837b (diff) | |
download | otp-d82c450402b4fe030befc28cc77e3bc2c07001c1.tar.gz otp-d82c450402b4fe030befc28cc77e3bc2c07001c1.tar.bz2 otp-d82c450402b4fe030befc28cc77e3bc2c07001c1.zip |
Merge branch 'sverk/enif_inspect-memleak/OTP-9668'
* sverk/enif_inspect-memleak/OTP-9668:
erts: Fix memory leak of enif_inspect_* on independent environment
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data/nif_SUITE.c')
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c index 35f54d62c5..7d7903af25 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c +++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c @@ -1431,6 +1431,26 @@ static ERL_NIF_TERM reverse_list(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar return rev_list; } +static ERL_NIF_TERM otp_9668_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + /* Inspect in process independent env */ + ErlNifEnv* myenv = enif_alloc_env(); + ERL_NIF_TERM mycopy = enif_make_copy(myenv, argv[0]); + ErlNifBinary obin, cbin; + + if ((enif_inspect_binary(env, argv[0], &obin) + && enif_inspect_binary(myenv, mycopy, &cbin)) + || + (enif_inspect_iolist_as_binary(env, argv[0], &obin) + && enif_inspect_iolist_as_binary(myenv, mycopy, &cbin))) + { + assert(obin.size == cbin.size); + assert(memcmp(obin.data, cbin.data, obin.size) == 0); + } + enif_free_env(myenv); + return atom_ok; +} + static ErlNifFunc nif_funcs[] = { {"lib_version", 0, lib_version}, @@ -1478,7 +1498,8 @@ static ErlNifFunc nif_funcs[] = {"send_term", 2, send_term}, {"reverse_list",1, reverse_list}, {"echo_int", 1, echo_int}, - {"type_sizes", 0, type_sizes} + {"type_sizes", 0, type_sizes}, + {"otp_9668_nif", 1, otp_9668_nif} }; ERL_NIF_INIT(nif_SUITE,nif_funcs,load,reload,upgrade,unload) |