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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 0FB3ABC0B for ; Tue, 26 Dec 2006 19:33:18 +0100 (CET) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBQIXFF3003521 for ; Tue, 26 Dec 2006 19:33:17 +0100 Received: from ppp14-213.lns2.syd7.internode.on.net (HELO rosella) ([59.167.14.213]) by ipmail02.adl2.internode.on.net with ESMTP; 27 Dec 2006 05:03:14 +1030 X-IronPort-AV: i="4.12,211,1165152600"; d="scan'208"; a="64861143:sNHT73314766" Subject: Re: [Caml-list] allocating memory for c-structures From: skaller To: micha Cc: OCaml Mailing List In-Reply-To: <459166C7.4080005@fantasymail.de> References: <459166C7.4080005@fantasymail.de> Content-Type: text/plain Date: Wed, 27 Dec 2006 05:33:09 +1100 Message-Id: <1167157989.5675.18.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45916AEB.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; allocating:01 0100,:01 malloc:01 interfacing:01 lib:01 malloc:01 ocaml:01 pointers:01 sourceforge:01 wrote:01 caml-list:01 strings:01 structures:02 external:02 objects:02 On Tue, 2006-12-26 at 19:15 +0100, micha wrote: > Normaly I allocate memory for c-structures with malloc or with "new" for > c++ objects. Some time ago a read about a library which places external > structures in strings of the interfacing languages (it was a scheme lib > I think). So instead of using malloc or new I would allocate an > ocaml-string and put the c-structure there. So it will be free by the gc. > That seems o.k. for me, any comments? I'm missing something? I don't believe Ocaml guarantees the contents of a string will remain in a fixed location .. it might move the storage to a new address .. so pointers into the structure might dangle. -- John Skaller Felix, successor to C++: http://felix.sf.net