[erlang-questions] FFI for Erlang: patches and draft EEP

Claes Wikstrom <>
Tue Sep 11 18:11:04 CEST 2007


Alceste Scalas wrote:

> In the current FFI implementation, strings are just pointers, and the
> caller should know what to do with them.  A binary may be obtained from
> a string with a bit of Erlang and side-effects:
> 
>         StrPtr = ffi:call(Port, {give_me_a_string}, {pointer}),
>         StrLen = ffi:call(Port, {strlen, StrPtr}, {size_t, pointer})+1,
>         StrBin = <<0:StrLen>>,
>         ffi:call(Port, {strcpy, StrBin, StrPtr},
>         {pointer,pointer,pointer})
> 

ok -  a bit ugly - but ok.


/klacke



More information about the erlang-questions mailing list