From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id AE7DDBC57 for ; Tue, 7 Sep 2010 23:13:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq4DALtHhkyK54gDgWdsb2JhbACDGZ1vFQEBFiIir2yRXYEigyd0BIoY X-IronPort-AV: E=Sophos;i="4.56,330,1280700000"; d="scan'208";a="56815771" Received: from rouge.crans.org ([138.231.136.3]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 07 Sep 2010 23:13:13 +0200 Received: from localhost (localhost.crans.org [127.0.0.1]) by rouge.crans.org (Postfix) with ESMTP id CDD5F85FF; Tue, 7 Sep 2010 23:13:12 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at crans.org Received: from rouge.crans.org ([10.231.136.3]) by localhost (rouge.crans.org [10.231.136.3]) (amavisd-new, port 10024) with LMTP id OC92Fo3ULwYT; Tue, 7 Sep 2010 23:13:12 +0200 (CEST) Received: from [192.168.39.1] (fbx.up7.fr [88.185.141.188]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rouge.crans.org (Postfix) with ESMTPSA id 8825485E1; Tue, 7 Sep 2010 23:13:12 +0200 (CEST) Message-ID: <4C86AABC.3010501@glondu.net> Date: Tue, 07 Sep 2010 23:12:28 +0200 From: =?UTF-8?B?U3TDqXBoYW5lIEdsb25kdQ==?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100805 Icedove/3.0.6 MIME-Version: 1.0 To: Paolo Donadeo Cc: OCaml mailing list , OCaml-Lua devel ML Subject: Re: [Caml-list] C binding and GC interaction: storing values outside the heap References: In-Reply-To: X-Enigmail-Version: 1.0.1 OpenPGP: id=49881AD3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; typedef:01 struct:01 ocaml:01 ocaml:01 alloc:01 alloc:01 sizeof:01 phane:98 steph:98 phane:98 heap:01 caml-list:01 data:02 data:02 callback:02 Le 07/09/2010 22:58, Paolo Donadeo a =C3=A9crit : > I'm writing a Lua API binding > [...] > typedef struct ocaml_data > { > value state_value; > value panic_callback; > } ocaml_data; > [...] > /* alloc space for the register entry */ > ocaml_data *data =3D (ocaml_data*)caml_stat_alloc(sizeof(ocaml_data)= ); > caml_register_global_root(&(data->panic_callback)); > data->panic_callback =3D *default_panic_v; Why don't you call caml_register_global_root on &(data->state_value) as well? --=20 St=C3=A9phane