<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 4:23 AM, Ildar Khizbulin <span dir="ltr"><<a href="mailto:herr.hizel@gmail.com" target="_blank">herr.hizel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
can I transfer resource from one nif to another nif?<br>
<br>
For example in first, i write:<br>
<br>
capture.c:<br>
<br>
static ErlNifResourceType *f_resource;<br>
<br>
capture_f() {<br>
frame_t* f = enif_alloc_resource(f_<wbr>resource, sizeof(frame_t));<br>
f_term = enif_make_resource_binary(env, f, ....<br>
ret = enif_make_tuple2(env, ok_atom, f_term);<br>
enif_release_resource(f);<br>
return ret;<br>
}<br>
<br>
load() {<br>
if(!f_resource)<br>
f_resource = enif_open_resource_type(env, NULL, "f_res", flags, NULL); </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
}<br>
<br>
in second<br>
<br>
hi.c:<br>
<br>
static ErlNifResourceType *f_resource;<br>
<br>
process_f() {<br>
struct frame_t *f;<br>
if (!enif_get_resource(env, argv[0], f_resource, (void **)&f)) { ///<- FAIL<br>
<br>
<br>
}<br>
<br>
load() {<br>
if(!f_resource)<br>
f_resource = enif_open_resource_type(env, NULL, "f_res", flags, NULL);<br></blockquote><div><br></div><div>Are you including ERL_NIF_RT_TAKEOVER in your flags value here?</div><div><br></div><div>--steve</div></div></div></div>