caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] GC with C issues
Date: Thu, 3 Feb 2005 13:52:37 +0100	[thread overview]
Message-ID: <7B4ADC81-75E2-11D9-866D-000D9345235C@inria.fr> (raw)
In-Reply-To: <20050203113155.GA1860@cradle>

On Feb 3, 2005, at 12:31, ronniec95@lineone.net wrote:

>>  Field (retVal, 0) = (value) x;
>
> Hmm... I thought I was only supposed to do that when using
> alloc_small/alloc_shr interface? However using your method does work in
> this small example though I'm worried about if something unexpected 
> will
> happen in more 'real-life' code...

Since retVal has the "Abstract" tag, its contents is none of the GC's
business, so you don't need to use Store_field to tell it about
assignments.

On the other hand, depending on the bit-pattern of (the value of) x,
you might crash the GC if you use Store_field.  In this case, x is an
aligned pointer outside the heap, so you're safe either way.

But the proper way is to store directly with Field.

If you want to be pedantic, it's not really a field but a bunch of bytes
so the even more proper way is to write:

   * (someObject *) Bp_val (retVal) = x;

-- Damien


      parent reply	other threads:[~2005-02-03 12:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-03 10:58 ronniec95
2005-02-03 11:06 ` [Caml-list] " Daniel Bünzli
2005-02-03 11:25   ` ronniec95
2005-02-03 11:16 ` Olivier Andrieu
2005-02-03 11:31   ` ronniec95
2005-02-03 12:50     ` Olivier Andrieu
2005-02-03 12:52     ` Damien Doligez [this message]

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=7B4ADC81-75E2-11D9-866D-000D9345235C@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@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).