[erlang-questions] Are binaries relocatable?
Hynek Vychodil
vychodil.hynek@REDACTED
Thu Aug 28 15:09:57 CEST 2014
Hi all,
I would like to know if binaries are relocatable. If I have binary parameter
ErlNifBinary bin;
if (!enif_inspect_binary(env, argv[0], &bin))
return enif_make_badarg(env);
I store binary in mine own environment
ErlNifEnv *priv_env = enif_alloc_env();
enif_make_copy(priv_env, argv[0]);
Can I then rely on bin.data pointing into same memory until I free
enif_free_env(priv_env) ? I'm asking because I would like to avoid copying
and share data or even return it using enif_make_resource_binary to catch
and
count references.
I have code which makes copy of binary data but when I switch to reference
bin.data it hangs whole VM. I would like to know if I make some mistake in
mine code and it should work or it is wrong idea at all.
Thanks
Hynek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140828/9a4a1368/attachment.htm>
More information about the erlang-questions
mailing list