Skip to content

Commit

Permalink
Fix error for upgrades and reloads.
Browse files Browse the repository at this point in the history
If the reload and upgrade functions are NULL they will cause any
attempt at reloading or upgrading the NIF to fail. We don't have
any sort of state that needs to be managed so simple definitions
that simply return 0 should be all that's required.
  • Loading branch information
davisp committed Mar 11, 2011
1 parent 42cc78a commit 3cf95ca
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions c_src/json.c
Expand Up @@ -4,7 +4,19 @@ ERL_NIF_TERM encode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
ERL_NIF_TERM decode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

int
on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM info)
{
return 0;
}

int
on_reload(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM info)
{
return 0;
}

int
on_upgrade(ErlNifEnv* env, void** priv_data, void** old_data, ERL_NIF_TERM info)
{
return 0;
}
Expand All @@ -15,4 +27,4 @@ static ErlNifFunc nif_funcs[] =
{"decode", 1, decode}
};

ERL_NIF_INIT(json, nif_funcs, &on_load, NULL, NULL, NULL);
ERL_NIF_INIT(json, nif_funcs, &on_load, &on_reload, &on_upgrade, NULL);

0 comments on commit 3cf95ca

Please sign in to comment.