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

Alceste Scalas alceste@REDACTED
Tue Sep 11 16:07:54 CEST 2007


Il giorno mar, 11/09/2007 alle 15.11 +0200, Vlad Dumitrescu ha scritto:
> When it comes to allocating memory, is the idea that the Erlang
> program will call malloc and free?

It is possible to do so, but it ultimately depends on how the external
code is interfaced to Erlang.  When creating a C library binding, the
FFI calls could (and should) be hidden in the guts of a nice, Erlang-ish
API.

However, if one wants to develop something like ESDL [1], (i.e. an
almost direct mapping between C and Erlang functions calls), then it is
possible (and easy) to do it.


> Filling buffers would be done by calling memcpy from a binary term?

Yes (on the C side, you get the pointer to the beginning of binary
data).

> How about returned buffers, how to convert them to Erlang binaries?

See my previous answer to Claes Wikstrom.

Regards,

alceste

Notes:

    [1] ESDL: http://esdl.sourceforge.net/

-- 
Alceste Scalas <alceste@REDACTED>
CRS4 - http://www.crs4.it/




More information about the erlang-questions mailing list