Version franaise
Home About Download Resources Contact us
Browse thread
Garbage Collector on NetBSD
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dam <eg.damy@g...>
Subject: Garbage Collector on NetBSD
Hi,

I simply want to interface a C function with OCaml.

OCaml source:
type s_img = int * int * string array
external load_img : string -> s_img = "caml_load_img"

C source:
value caml_load(s_img *img)
{
  CAMLparam0 ();
  CAMLlocal1 (v);
  unsigned char **nimg;

  /*
  ** Dynamic allocation (and initialization) of nimg with malloc
(NULL-terminated).
  ** The dimensions are `` nimg[img->height + 1][img->width] ''
  */

  v = alloc_tuple(3);
  Store_field(v, 0, Val_int(img->height));
  Store_field(v, 1, Val_int(img->width));
  Store_field(v, 2, caml_copy_string_array(nimg));

  /* Some calls to the free function */

  CAMLreturn (v);
}

value        caml_load_img(value filename)
{
  CAMLparam1 (filename);
  char        *s = String_val(filename);
  s_img      *img;

  /* Allocation of the s_img structure with C functions */

  CAMLreturn (caml_load(img));
}

The source code is working on Debian but does not on NetBSD (release 3.0.1)
where the GC raise Out_memory ! I am using on both architectures the version
3.08.3 of OCaml.

Thanks.

-- 
Damien `Dam' Lefortier
Hwr cwom mearg? Hwr cwom mago?
            -- The Wanderer v. 92a
EPITA Promo 2010