caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Brown <caml-list@davidb.org>
To: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
Cc: Richard Jones <rich@annexia.org>, caml-list@inria.fr
Subject: Re: [Caml-list] Garbage collection and a reference counting library
Date: Thu, 11 Dec 2003 08:57:32 -0800	[thread overview]
Message-ID: <20031211165732.GA26478@davidb.org> (raw)
In-Reply-To: <16344.35301.538267.517515@gargle.gargle.HOWL>

On Thu, Dec 11, 2003 at 04:14:45PM +0100, Jean-Christophe Filliatre wrote:

>  > static value
>  > Val_voidptr (void *ptr)
>  > {
>  >   value rv = alloc (1, Abstract_tag); /* XXX Is this correct? */
>  >   Field(rv, 0) = (value) ptr;
>  >   return rv;
>  > }
> 
> A first remark: to be GC-friendly you have to use CAMLlocal1 to
> declare rv and CAMLreturn instead of return.

Although, it isn't necessary in this situation.  GC only happens on
allocation, so the value 'rv' never has an opportunity to change, so
there is nothing wrong with this function.

But, if you're not sure, it is better to err being too safe rather than
not being safe enough.  Performance is the only issue.

Dave

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-12-11 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-11 14:36 Richard Jones
2003-12-11 15:14 ` Jean-Christophe Filliatre
2003-12-11 16:57   ` David Brown [this message]
2003-12-16 22:55 ` Damien Doligez

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=20031211165732.GA26478@davidb.org \
    --to=caml-list@davidb.org \
    --cc=Jean-Christophe.Filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /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).