>
>
>
> * passing a string using 'string' makes a copy in either direction.
> Furthermore,
>
> - the copy created when passing a string from OCaml to C lives for
> the lifetime of the C call.
> (It's possible this will be strengthened in the future:
> https://github.com/ocamllabs/ocaml-ctypes/issues/556)
>
> - the copy created when passing a string from C to OCaml is a
> regular OCaml string, subject to usual GC behaviour. Ctypes makes no
> attempt to deallocate the memory used by the original C string.
>
In the case where a C function takes and returns the same string, does a
signature of [string @-> returning string] also work? In other words, does
the input string live long enough to ensure the output string is created?
Silly example:
char * foo (char * p) { return (p+1); }
I guess this gets more complex with structures and the like. More
generally do the arguments to a function call live long enough to create
[view]s of a returned value?
-Andy
_______________________________________________
Ctypes mailing list
[email protected]
http://lists.ocaml.org/listinfo/ctypes