Version française
Home     About     Download     Resources     Contact us    
Browse thread
Returning caml values from C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Olivier Andrieu <oandrieu@g...>
Subject: Re: [Caml-list] Returning caml values from C
On 8/22/07, andrew.p.cone <andrew.p.cone@gmail.com> wrote:
>
> Hi everybody.
>
> I have a C function that, given a list of caml values, returns a certain
> sublist of those values.
>
> Currently, I have the C code build up a caml list using caml_alloc and
> Store_field. But when I try to access those values in caml, I get a
> segfault.
>
> I suspect the GC is deleting the input list, because it doesn't realize I've
> made something new that refers to some of those values. How do I tell the GC
> that something refers to some value?

by registering the value with the macros CAMLparam* and CAMLlocal*
cf. http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#htoc229

-- 
  Olivier