Erlang, pass an nif object between functions
I write a C nif code and in function new , it creates a stack struct with enif_alloc_resource and returns that. when i use function enif_make_resources , it always returns <<>> in erlang. Here is my C code: #include "erl_nif.h" static ErlNifResourceType *MEM_RESOURCE; typedef struct { int n; int ps; int pe; ERL_NIF_TERM *data; } Stack; Stack *new(ErlNifEnv *env, int size) { Stack *s = (Stack*) enif_alloc_resource(MEM_RESOURCE, sizeof(Stack)); s->n = size; s->ps = 0; s->pe = size - 1; s->data = enif_alloc(sizeof(ERL_NIF_TERM) * size); return s; } static ERL_NIF_TERM new_nif(ErlNifEnv* env, int