Skip to content

2 small bugfixes for nif-examples resources #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/resources/c_src/resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ open_resource(ErlNifEnv* env)
const char* mod = "resources";
const char* name = "Example";
int flags = ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER;
Tracker* tracker;

RES_TYPE = enif_open_resource_type(env, mod, name, free_res, flags, NULL);
if(RES_TYPE == NULL) return -1;
Expand All @@ -40,7 +39,7 @@ load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)

atom_ok = enif_make_atom(env, "ok");

tracker = (Tracker*) enif_alloc(sizeof(Tracker));
Tracker* tracker = (Tracker*) enif_alloc(sizeof(Tracker));
tracker->count = 0;
*priv = (void*) tracker;

Expand All @@ -56,7 +55,7 @@ reload(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
}

static int
reload(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM load_info)
upgrade(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM load_info)
{
if(open_resource(env) == -1) return -1;
return 0;
Expand Down