Version française
Home     About     Download     Resources     Contact us    
Browse thread
AW: [Caml-list] segfault in caml_copy_string
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bauer, Christoph <Christoph.Bauer@l...>
Subject: AW: [Caml-list] segfault in caml_copy_string
> 
> caml_copy_string actually allocates a *garbage-collected* 
> string, so you need to tell about its result to the GC. Try instead
> 
>  CAMLprim value getparam(value request, value key){
>    CAMLparam2(request, key);
>    CAMLlocal1(result);
>    result = caml_copy_string("test");
>    CAML_return(result);
> }
> 
> (to understand why, read any material on precise moving garbage
> collectors)

Thanks for the fast response.
But ocaml/stdlib/sys.c contains this function:

CAMLprim value caml_sys_getenv(value var)
{
  char * res;

  res = getenv(String_val(var));
  if (res == 0) caml_raise_not_found();
  return caml_copy_string(res);
}

I found out that it is a links problem because of mixing a 
static library and a DLL.

best regards,
Christoph Bauer