From: "Olivier Andrieu" <oandrieu@nerim.net>
To: "Jean-Marc EBER" <jeanmarc.eber@lexifi.com>
Cc: "Ocaml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] question about the OCaml/C interface
Date: Wed, 9 May 2007 11:39:02 +0200 [thread overview]
Message-ID: <95513600705090239v6e05e802o729b77cc7a24da7c@mail.gmail.com> (raw)
In-Reply-To: <46419449.5090404@lexifi.com>
Hi,
On 5/9/07, Jean-Marc EBER <jeanmarc.eber@lexifi.com> wrote:
> Hello to all,
>
> I have a little technical question about the OCaml/C interface:
>
> Is the following code "correct":
yes
> CAMLprim value my_func(...)
> {
> CAMLlocal2(ret);
> ...
> result = ...
> ret = caml_alloc(5, 0);
> Store_field(ret, 0, caml_copy_double(result));
> ...
> CAMLreturn (ret);
> }
>
> or, arguing that [caml_copy_double] allocates and may therfore launch a gc cycle
> that may therefore modify [ret], one must write:
no, that's the whole point of this Store_field macro, cf. its definition:
#define Store_field(block, offset, val) do{ \
mlsize_t caml__temp_offset = (offset); \
value caml__temp_val = (val); \
caml_modify (&Field ((block), caml__temp_offset), caml__temp_val); \
}while(0)
--
Olivier
next prev parent reply other threads:[~2007-05-09 9:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 9:28 Jean-Marc EBER
2007-05-09 9:39 ` Olivier Andrieu [this message]
2007-05-09 13:47 ` [Caml-list] " Markus Mottl
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=95513600705090239v6e05e802o729b77cc7a24da7c@mail.gmail.com \
--to=oandrieu@nerim.net \
--cc=caml-list@inria.fr \
--cc=jeanmarc.eber@lexifi.com \
/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