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 NAA08673; Mon, 2 Jun 2003 13:40:35 +0200 (MET DST) 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 NAA08654 for ; Mon, 2 Jun 2003 13:40:33 +0200 (MET DST) Received: from dirty.research.bell-labs.com (ns1.research.bell-labs.com [204.178.16.6]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h52BeWH11495; Mon, 2 Jun 2003 13:40:32 +0200 (MET DST) Received: from grubby.research.bell-labs.com (H-135-104-2-9.research.bell-labs.com [135.104.2.9]) by dirty.research.bell-labs.com (8.12.9/8.12.9) with ESMTP id h52BeTHa074870; Mon, 2 Jun 2003 07:40:29 -0400 (EDT) Received: from mcs.research.bell-labs.com (mcs.research.bell-labs.com [135.104.32.15]) by grubby.research.bell-labs.com (8.12.9/8.12.9) with ESMTP id h52BeMc6099338; Mon, 2 Jun 2003 07:40:22 -0400 (EDT) Received: from dhcp50114.cs.bell-labs.com (dhcp50114.cs.bell-labs.com [135.104.50.114]) by mcs.research.bell-labs.com (8.12.9/8.12.9) with ESMTP id h52BeCf4554962; Mon, 2 Jun 2003 07:40:12 -0400 (EDT) Subject: Re: [Caml-list] Question about register_global_root From: Jerome Simeon To: Damien Doligez Cc: Maas-Maarten Zeeman , Chris Hecker , "Mary F. Fernandez" , caml-list@inria.fr In-Reply-To: References: Content-Type: text/plain Organization: Lucent Technologies Message-Id: <1054553849.31726.7.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 02 Jun 2003 07:37:30 -0400 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; jerome:01 simeon:01 caml-list:01 damien:01 hecker:01 malloc:01 sizeof:01 val:01 interfacing:01 implemented:01 chris:01 caml:01 doligez:01 unit:03 pointer:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2003-06-01 at 15:53, Damien Doligez wrote: > On Sunday, June 1, 2003, at 12:50 PM, Maas-Maarten Zeeman wrote: > > > Chris Hecker wrote: > > > >> > >>> handlers = (value *) malloc(sizeof(value)); > >>> register_global_root(handlers); > >> > >> > >> Shouldn't you init *handlers to Val_unit before calling > >> register_global_root() as well? > > > > The manual explicitly tells that register_global_root should be called > > before any valid value is stored in it for the first time, like > > Val_unit. See Rule 4 of Interfacing C with Objective Caml in the > > manual. > > > > So I think it is ok the way it is implemented. > > I'm afraid Chris is right and the manual is wrong. > Us poor developers could use a little improvement in the doc in this area. Some additional example doing this feature in the doc would help... - Jerome > You can store Val_unit before you call register_global_root, because > Val_unit is not a pointer into the Caml heap. > You must store a valid value before the first allocation that follows > register_global_root. > You can store an allocated value (a pointer into the Caml heap) before > or after calling register_global_root, but it must be after the last > allocation that precedes register_global_root, and before the first > allocation that succeeds it. > > At any rate, storing Val_unit before you call register_global_root is > safe and does not cost much CPU time. > > -- Damien -- Jerome Simeon Lucent Technologies ------------------- 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