caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: Thomas Braibant <thomas.braibant@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] C bindings: memory managment
Date: Sat, 13 Aug 2011 15:40:11 +0100	[thread overview]
Message-ID: <20110813144011.GA25146@annexia.org> (raw)
In-Reply-To: <CAHR=VkzkSmhc-Op6Snf7E55whXWKnWGhjm2cd+RuoZv0Wouo-Q@mail.gmail.com>

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

      parent reply	other threads:[~2011-08-13 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12 10:10 Thomas Braibant
2011-08-12 10:56 ` David Allsopp
2011-08-12 14:15 ` Romain Beauxis
2011-08-13 14:40 ` Richard W.M. Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110813144011.GA25146@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    --cc=thomas.braibant@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).