[ocaml-ctypes] Arrays from C to Ocaml
Clark Gaebel
cgaebel at janestreet.com
Tue Jan 7 19:34:31 GMT 2014
Ok. Thanks anyways!
- Clark
On Tue, Jan 7, 2014 at 11:04 AM, Jeremy Yallop <yallop at gmail.com> wrote:
> On 7 January 2014 13:45, Clark Gaebel <cgaebel at janestreet.com> wrote:
> > What's the proper way in ctypes to interface with the following api:
> >
> > void read_some_data(context* ctx, void* buffer, int length);
> >
> > where read_some_data pulls some private data out of the given opaque
> context
> > and writes it into the given buffer, without blocking internally.
> >
> > Ideally, I'd want something in OCaml that looks like:
> >
> > val read_some_data : ctx -> len:int -> string
> >
> > and the only way I see of doing this is going through bigstring first.
> But
> > this means two copies: one from C -> bigstring and one from bigstring ->
> > string.
>
> For the moment ctypes doesn't provide any way to pass OCaml heap
> addresses to C, so moving between OCaml strings and C arrays always
> involves a copy.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20140107/54a488b5/attachment-0001.html>
More information about the Ctypes
mailing list