In this particular case, I would use enif_alloc_resource
. Create a struct to contain your pointer and establish it as a resource object.
You could also encode it as a binary, but I would recommend against that, as it would allow erlang functions to modify the contents before passing it back in. Resource types are opaque from the erlang side and cannot be modified.