caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dam <eg.damy@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Garbage Collector on NetBSD
Date: Mon, 19 Feb 2007 16:03:00 +0100	[thread overview]
Message-ID: <b45cc0660702190703t3e41826oc0c902e37155de5d@mail.gmail.com> (raw)

[-- 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 --]

                 reply	other threads:[~2007-02-19 15:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b45cc0660702190703t3e41826oc0c902e37155de5d@mail.gmail.com \
    --to=eg.damy@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).