[ocaml-ctypes] Arrays from C to Ocaml

Clark Gaebel cgaebel at janestreet.com
Tue Jan 7 13:45:20 GMT 2014


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.

Is there a better way?

  - Clark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20140107/47a52110/attachment.html>


More information about the Ctypes mailing list