From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA20478; Thu, 11 Dec 2003 17:57:44 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA20467 for ; Thu, 11 Dec 2003 17:57:43 +0100 (MET) Received: from mail.davidb.org (adsl-64-172-240-129.dsl.sndg02.pacbell.net [64.172.240.129]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hBBGvgr02465 for ; Thu, 11 Dec 2003 17:57:42 +0100 (MET) Received: from davidb by mail.davidb.org with local (Exim 3.36 #1 (Debian)) id 1AUU84-0006u2-00; Thu, 11 Dec 2003 08:57:32 -0800 Date: Thu, 11 Dec 2003 08:57:32 -0800 From: David Brown To: Jean-Christophe Filliatre Cc: Richard Jones , caml-list@inria.fr Subject: Re: [Caml-list] Garbage collection and a reference counting library Message-ID: <20031211165732.GA26478@davidb.org> References: <20031211143640.GA21082@redhat.com> <16344.35301.538267.517515@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16344.35301.538267.517515@gargle.gargle.HOWL> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 caml-list:01 filliatre:01 val:01 alloc:01 camllocal:01 camlreturn:01 garbage:01 dave:03 wrote:03 library:03 abstract:03 static:06 dec:07 0100,:08 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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