<div dir="ltr"><div>Hi all,</div><div>I would like to know if binaries are relocatable. If I have binary parameter</div><div><br></div><div> ErlNifBinary bin;</div><div> if (!enif_inspect_binary(env, argv[0], &bin))</div>
<div> return enif_make_badarg(env);</div><div><br></div><div>I store binary in mine own environment</div><div><br></div><div> ErlNifEnv *priv_env = enif_alloc_env();</div><div> enif_make_copy(priv_env, argv[0]);</div>
<div><br></div><div>Can I then rely on bin.data pointing into same memory until I free</div><div>enif_free_env(priv_env) ? I'm asking because I would like to avoid copying</div><div>and share data or even return it using enif_make_resource_binary to catch and</div>
<div>count references.</div><div><br></div><div>I have code which makes copy of binary data but when I switch to reference</div><div>bin.data it hangs whole VM. I would like to know if I make some mistake in</div><div>mine code and it should work or it is wrong idea at all.</div>
<div><br></div><div>Thanks</div><div> Hynek</div></div>