From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id E7352BC0A for ; Mon, 19 Feb 2007 16:03:02 +0100 (CET) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1JF31I9027381 for ; Mon, 19 Feb 2007 16:03:02 +0100 Received: by wr-out-0506.google.com with SMTP id 70so1629016wra for ; Mon, 19 Feb 2007 07:03:00 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=HtyktDsac33oo/Mln9Z0fK5yVF7WKh5pDfy6Td8oGNvcTMaTKm9H+uC6QnlwQolHAZ2HCwZMkXybEeW03dNYXEcEtpdSUGAM+mbDSzGITOhhp7Gg+NwEi1y7lxqJY0AsXdArlrN+RiI67AtKyRJgjQc7rJNSmDp6lp1UzLMg43k= Received: by 10.115.95.1 with SMTP id x1mr2930232wal.1171897380186; Mon, 19 Feb 2007 07:03:00 -0800 (PST) Received: by 10.114.158.16 with HTTP; Mon, 19 Feb 2007 07:03:00 -0800 (PST) Message-ID: Date: Mon, 19 Feb 2007 16:03:00 +0100 From: Dam To: caml-list@yquem.inria.fr Subject: Garbage Collector on NetBSD MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_28274_15910499.1171897380010" X-j-chkmail-Score: MSGID : 45D9BC25.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45D9BC25.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 camlparam:01 malloc:01 alloc:01 val:01 val:01 camlreturn:01 camlparam:01 camlreturn:01 3.08.3:01 damien:01 malloc:01 alloc:01 3.08.3:01 ------=_Part_28274_15910499.1171897380010 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I simply want to interface a C function with OCaml. OCaml source: type s_img =3D int * int * string array external load_img : string -> s_img =3D "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 =3D 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 =3D 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 versio= n 3.08.3 of OCaml. Thanks. --=20 Damien `Dam' Lefortier Hw=E6r cwom mearg? Hw=E6r cwom mago? -- The Wanderer v. 92a EPITA Promo 2010 ------=_Part_28274_15910499.1171897380010 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,

I simply want to interface a C function with OCaml.

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

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

  /*
  ** Dynamic allo= cation (and initialization) of nimg with malloc (NULL-terminated).
&nbs= p; ** The dimensions are `` nimg[img->height + 1][img->width] '&#= 39;
  */

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

  /* Some call= s to the free function */

  CAMLreturn (v);
}

value  &= nbsp;     caml_load_img(value filename)
{
  CAMLp= aram1 (filename);
  char        *s = =3D 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=E6r cwom mearg? = Hw=E6r cwom mago?
         =    -- The Wanderer v. 92a
EPITA Promo 2010 ------=_Part_28274_15910499.1171897380010--