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 DAA31694; Wed, 2 Jul 2003 03:20:46 +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 DAA31782 for ; Wed, 2 Jul 2003 03:20:44 +0200 (MET DST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h621Khj00922 for ; Wed, 2 Jul 2003 03:20:43 +0200 (MET DST) Received: from mailbox.samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id CF1C41DD3 for ; Tue, 1 Jul 2003 21:20:42 -0400 (EDT) Received: from tide105.microsoft.com ([207.46.228.14]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Tue, 1 Jul 2003 18:20:42 -0700 (PDT) Message-ID: <10335.207.46.228.14.1057108842.squirrel@mailbox.samurai.com> Date: Tue, 1 Jul 2003 18:20:42 -0700 (PDT) Subject: [Caml-list] alloc_final and local value variables From: "Neil Conway" To: caml-list@inria.fr User-Agent: SquirrelMail/1.4.0 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Spam: no; 0.00; alloc:01 val:01 sizeof:01 interfacing:01 ocaml:01 caml:01 int:01 chunk:03 variables:06 uses:06 blocks:06 objective:07 manual:07 i'm:07 memory:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk In Chapter 12 of the O'Reilly book on Ocaml, section "Creating and modifying Objective CAML values from C", this example code is given for wrapping a heap-allocated chunk of memory in an Ocaml value: value create (value s) { value block ; block = alloc_final (2, finalize_it,Int_val(s)*sizeof(IntTab),100000) ; Field(block,1) = (value) alloc_it(Int_val(s)) ; return block ; } This code uses a "value" local, but doesn't declare it with one of the CAMLlocalN variables, as the Ocaml Manual says is necessary (Ocaml Manual, "Interfacing C with Objective Caml", Section 18.5.1, Rule 2). Is this code above correct? Thanks in advance, Neil P.S. I'm aware that custom blocks are now available, but alloc_final does everything I need... ------------------- 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