[erlang-questions] using strings with NIF

Jarrod Roberson jarrod@REDACTED
Wed Dec 9 05:25:30 CET 2009


On Tue, Dec 8, 2009 at 11:08 PM, Jason Frame <jasonwframe@REDACTED> wrote:
> Hi,
>
> I am trying to use a string as an argument with NIF. I can't work out
> how to extract the string on the c side though. Using a int is quite
> simple with the enif_get_int function but there doesn't seem be a
> similar function for strings. I have tried encoding a tuple with
> term_to_binary then using erl_decode and then use erl_element and the
> associated functions to extract the string. But it fails with a
> segfault and I'm sure there is probably a better way to do this.

I could be wrong, but I would think that

ERL_NIF_TERM enif_make_list(ErlNifEnv* env, unsigned cnt, ...)

is what you want, since in Erlang "strings" are just lists of bytes.


More information about the erlang-questions mailing list