Hi Jeremy

> Em 26 de jul de 2016, às 19:26, Jeremy Yallop <[email protected]> escreveu:
> 
> In many cases you'll be able to avoid the call to 'memcpy' by using
> 'allocate' to create an initialized object, like this:
> 
>   let p = allocate int 42 in
>   setf v buffer (coerce (ptr int) (ptr void) p)

For strings it seems from the description at [1] that using this method will 
cause problems if the C object lives longer than the OCaml object.

Is there a way to copy an OCaml string into the buffer with stock a Ctypes or 
is memcpy the way to go here?

[1] https://github.com/ocamllabs/ocaml-ctypes/issues/159

Best,
Andre
_______________________________________________
Ctypes mailing list
[email protected]
http://lists.ocaml.org/listinfo/ctypes

Reply via email to