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 FAA17141; Sun, 21 Oct 2001 05:23:38 +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 FAA16470 for ; Sun, 21 Oct 2001 05:23:37 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f9L3Nb510547 for ; Sun, 21 Oct 2001 05:23:37 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id FAA01428 for caml-list@inria.fr; Sun, 21 Oct 2001 05:23:37 +0200 Date: Sun, 21 Oct 2001 05:23:37 +0200 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] Troubles with C->Caml Message-ID: <20011021052337.A1404@verdot.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from malc@pulsesoft.com on Sun, Oct 21, 2001 at 03:36:04AM +0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Sun, Oct 21, 2001 at 03:36:04AM +0400, malc wrote: > result = alloc_small (1, 2); > Field (result, 0) = ; > Field (result, 1) = Extract_exception (res); FAQ. When calling allocating functions, the GC may move the values of the heap. The variable "res", of type "value", is actually a pointer to the heap. After the call to "alloc_small", its pointed value may have been moved by the GC, but "res" still points to the old area. The OCaml documentation explains you this point. You have to add specific code in the beginning and at the end of your function to tell the GC that you are using some variables of type "value". The functions to call have names CAMLparam, CAMLlocal, CAMLreturn, things like that, defined in "caml/memory.h". Read the documentation carefully because if you don't program it correctly, you can get memory fault at any time later. -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr