Browse thread
Wrapping OCaml function returning a variant
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-28 (12:50) |
From: | Serge Aleynikov <serge@h...> |
Subject: | Re: [Caml-list] Wrapping OCaml function returning a variant |
Joel Reymont wrote: > > On Mar 28, 2007, at 1:55 PM, Serge Aleynikov wrote: > >> If you are using caml_copy_string() or caml_alloc_string() they >> allocate strings on OCaml's heap, and will be automatically garbage >> collected. > > How do I pass a C string into OCaml if the assumption is that it will > not be modified? Do I still need to copy it with caml_copy_string? If you need to be able to access your C string value from OCaml, caml_copy_string is what you need. OTOH, if you want the string to be passed to OCaml as an opaque type (in which case OCaml won't be able to access its value directly, though the value will live on the C heap and can only be accessible from C) you can pass the string pointer using a Custom block (see section 18.9.2 http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html). Regards, Serge