From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7DEeIEN005270 for ; Sat, 13 Aug 2011 16:40:18 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EACaMRk5QRFuw/2dsb2JhbABBp3h3gUABAQU6OAcQCxgcEhQoIS6HVwK5D4VoXwSkCA X-IronPort-AV: E=Sophos;i="4.67,367,1309730400"; d="scan'208";a="115763899" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 13 Aug 2011 16:40:12 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.72) (envelope-from ) id 1QsFNj-00072m-Ik; Sat, 13 Aug 2011 15:40:11 +0100 Date: Sat, 13 Aug 2011 15:40:11 +0100 From: "Richard W.M. Jones" To: Thomas Braibant Cc: caml-list@inria.fr Message-ID: <20110813144011.GA25146@annexia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [Caml-list] C bindings: memory managment On Fri, Aug 12, 2011 at 12:10:17PM +0200, Thomas Braibant wrote: > The solutions I can imagine are: > - either to define Space.t as a record/tuple that contains a space* > and an OCaml list of the bodies that have been added. This seems a bit > of a duplication of the underlying C library. This is the way to do it. It's a pretty common problem (and a commonly overlooked problem IME), but you'll find it occurs in many C bindings. A couple of examples in libraries that I have been involved with: ocaml-libvirt (http://git.annexia.org/?p=ocaml-libvirt.git;a=summary) - The relationship between connections (owner) and domains (owned). ocamlode - Many objects are related, similar to your example. Rich. -- Richard Jones Red Hat