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 LAA14964; Fri, 20 Sep 2002 11:57:05 +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 LAA15276 for ; Fri, 20 Sep 2002 11:57:05 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8K9uv509266; Fri, 20 Sep 2002 11:56:57 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA13148; Fri, 20 Sep 2002 11:56:57 +0200 (MET DST) Date: Fri, 20 Sep 2002 11:56:57 +0200 From: Xavier Leroy To: "Yaron M. Minsky" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Bp_val and Data_custom_val Message-ID: <20020920115657.A15003@pauillac.inria.fr> References: <3D88DA09.4010906@cs.cornell.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3D88DA09.4010906@cs.cornell.edu>; from yminsky@CS.Cornell.EDU on Wed, Sep 18, 2002 at 03:54:49PM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I'm wondering if someone can help me out in understanding the difference > between Bp_val and Data_custom_val. Caml heap blocks are composed of a GC header and a number of words of data. Bp_val points to the first word of data: header data0 data1 data2 ... ^ | Bp_val For finalized and custom blocks, the first word of "data" holds a pointer to a record of functions (finalization functions, comparison functions, etc), and Data_custom_val points to the second word of data, i.e. the beginning of the user data space: header function data1 data2 ... pointer ^ | Data_custom_val > struct camldb { > DB *db; > int closed; > }; > > struct camltxn { > DB_TXN *txn; > int closed; > }; > > #define UW_db(v) (((struct camldb *)Bp_val(v))->db) > #define UW_db_closed(v) (((struct camldb *)Bp_val(v))->closed) This is incorrect, you should use Data_custom_val(v) instead of Bp_val(v), otherwise the db field will overwrite the function pointer at the beginning of the custom/finalized block. - Xavier Leroy ------------------- 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