From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 66172BCAE for ; Fri, 24 Jun 2005 13:16:46 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5OBGj8d017888 for ; Fri, 24 Jun 2005 13:16:46 +0200 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 NAA18637 for ; Fri, 24 Jun 2005 13:16:45 +0200 (MET DST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5OBGjJC008077 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 24 Jun 2005 13:16:45 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1DlmHP-00077V-00; Fri, 24 Jun 2005 12:23:27 +0100 Date: Fri, 24 Jun 2005 12:23:27 +0100 To: Daniel =?iso-8859-1?Q?B=FCnzli?= Cc: caml-list@inria.fr Subject: Re: [Caml-list] Wrapping a callback to OCaml code from C Message-ID: <20050624112327.GA26602@furbychan.cocan.org> References: <20050623214733.GA30897@furbychan.cocan.org> <20050624104050.GA23041@furbychan.cocan.org> <5CDC7A78-EE85-4C7E-A630-8CED51F8B614@epfl.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5CDC7A78-EE85-4C7E-A630-8CED51F8B614@epfl.ch> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 42BBEB9D.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42BBEB9D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 camlparam:01 camlreturn:01 val:01 val:01 const:01 char:01 camlparam:01 alloc:01 camlreturn:01 ocaml:01 notepad:01 ...:98 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Fri, Jun 24, 2005 at 01:15:16PM +0200, Daniel Bünzli wrote: > > Le 24 juin 05 à 12:40, Richard Jones a écrit : > > >On Thu, Jun 23, 2005 at 10:47:33PM +0100, Richard Jones wrote: > >[...] > > > >There was quite a delay in this posting appearing. In the meantime I > >think I've fixed the problem by adding CAMLparam0 .. CAMLlocal3 .. > >CAMLreturn0 around the callback wrapper function. > > I would like to understand why this is needed. Did you allocate > something with the gc in your Val_obj functions ? Yes. Val_obj is in fact a thin wrapper around this function: static inline value Val_voidptr (void *ptr, const char *) { CAMLparam0 (); CAMLlocal1 (rv); rv = caml_alloc (1, Abstract_tag); Field (rv, 0) = (value) ptr; CAMLreturn (rv); } and of course callback_wrapper calls callback2 which calls into OCaml code - rather a lot of allocation possibilities there! Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com