caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Garbage Collector on NetBSD
@ 2007-02-19 15:03 Dam
  0 siblings, 0 replies; only message in thread
From: Dam @ 2007-02-19 15:03 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1215 bytes --]

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
Hwær cwom mearg? Hwær cwom mago?
            -- The Wanderer v. 92a
EPITA Promo 2010

[-- Attachment #2: Type: text/html, Size: 1786 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-19 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 15:03 Garbage Collector on NetBSD Dam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).