From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7194BBB9C for ; Fri, 20 Jan 2006 16:27:03 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KFR2Uv025423 for ; Fri, 20 Jan 2006 16:27:03 +0100 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 QAA29499 for ; Fri, 20 Jan 2006 16:27:02 +0100 (MET) Received: from kraid.nerim.net (smtp-105-friday.nerim.net [62.4.16.105]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KFR2ad025412 for ; Fri, 20 Jan 2006 16:27:02 +0100 Received: from karryall.dnsalias.org (oandrieu.pck.nerim.net [213.41.240.180]) by kraid.nerim.net (Postfix) with ESMTP id 36B2E40EFD; Fri, 20 Jan 2006 16:27:01 +0100 (CET) Received: by karryall.dnsalias.org (Postfix, from userid 500) id D61BA596F15; Fri, 20 Jan 2006 16:27:01 +0100 (CET) From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17361.325.830020.552502@karryall.dnsalias.org> Date: Fri, 20 Jan 2006 16:27:01 +0100 To: "Bauer, Christoph" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Again C-Interface: caml_alloc_custom In-Reply-To: <26EB47FDD566A7469FC862DAF373792F07D738@kaiserslautern1.lmsintl.com> References: <26EB47FDD566A7469FC862DAF373792F07D738@kaiserslautern1.lmsintl.com> X-Mailer: VM 7.19 under Emacs 21.4.1 X-Miltered: at concorde with ID 43D10146.005 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43D10146.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 nerim:01 caml-list:01 c-interface:01 alloc:01 camlparam:01 camlreturn:01 const:01 camlparam:01 val:01 alloc:01 initialized:01 higher-level:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Bauer, Christoph [Friday 20 January 2006] : > Could be here a problem (CAMLparam+CAMLreturn in C-called function): > > static value copy_tcl_array(int objc, Tcl_Obj * const * objv) > { > CAMLparam0 (); > CAMLlocal2 (result, t); > int n; > > result = Val_int(0); > for (n = objc-1; n >= 0; --n) { > t = caml_alloc_small(2,0); > Field(t, 0) = alloc_tcl_obj( objv[n] ); ^^^^^^^^^^^^^ I guess alloc_tcl_obj creates the custom block. That's wrong because the block t you've just allocated with caml_alloc_small is not completely initialized yet. Either do this (safe, higher-level way): ,---- | t = caml_alloc (2, 0); | Store_field (t, 0, alloc_tcl_obj (objv[n])); | Store_field (t, 1, result); `---- or that (lower-level) : ,---- | CAMLlocal1(obj); | obj = alloc_tcl_obj (objv[n]); | t = caml_alloc_small (2, 0); | Field (t, 0) = obj; | Field (t, 1) = result; `---- -- Olivier