From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 11530BC69 for ; Wed, 9 May 2007 11:28:42 +0200 (CEST) Received: from smtp21.orange.fr (smtp21.orange.fr [80.12.242.46]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l499SfxO016253 for ; Wed, 9 May 2007 11:28:41 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2128.orange.fr (SMTP Server) with ESMTP id 8E4771C000AC for ; Wed, 9 May 2007 11:28:41 +0200 (CEST) Received: from [192.168.1.53] (APuteaux-154-1-85-116.w83-204.abo.wanadoo.fr [83.204.224.116]) by mwinf2128.orange.fr (SMTP Server) with ESMTP id 737121C000A8 for ; Wed, 9 May 2007 11:28:41 +0200 (CEST) X-ME-UUID: 20070509092841472.737121C000A8@mwinf2128.orange.fr Message-ID: <46419449.5090404@lexifi.com> Date: Wed, 09 May 2007 11:28:41 +0200 From: Jean-Marc EBER User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Ocaml Mailing List Subject: question about the OCaml/C interface Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46419449.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexifi:01 ocaml:01 ocaml:01 camlprim:01 alloc:01 camlreturn:01 allocates:01 camlprim:01 alloc:01 camlreturn:01 jeanmarc:01 eber:01 eber:01 jean-marc:01 jean-marc:01 Hello to all, I have a little technical question about the OCaml/C interface: Is the following code "correct": CAMLprim value my_func(...) { CAMLlocal2(ret); ... result = ... ret = caml_alloc(5, 0); Store_field(ret, 0, caml_copy_double(result)); ... CAMLreturn (ret); } or, arguing that [caml_copy_double] allocates and may therfore launch a gc cycle that may therefore modify [ret], one must write: CAMLprim value my_func(...) { ... CAMLlocal2(v, ret); ... result = ... ret = caml_alloc(5, 0); v = caml_copy_double(result); Store_field(ret, 0, v); ... CAMLreturn (ret); } I don't find a clear answer to that question in the documentation. Jean-Marc Eber