caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: lyn HONG <lynxiamen@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] What should the "size" in "caml_alloc_custom" be?
Date: Tue, 18 May 2010 10:58:39 -0400	[thread overview]
Message-ID: <AANLkTimvPmK_QGMlfNt578bxCknDk7ZprA0iNoolC91x@mail.gmail.com> (raw)
In-Reply-To: <87aarxitmv.fsf@frosties.localdomain>

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

On Tue, May 18, 2010 at 2:58 AM, Goswin von Brederlow <goswin-v-b@web.de>wrote:

> lyn HONG <lynxiamen@gmail.com> writes:
>
> > Hi all,
> >
> > I have a question about "allocating custom blocks" in "iterfacing C with
> object
> > Ocaml". when we call function "caml_alloc_custom(ops, size, used, max)"
> in the
> > C side, if the structure we want to allocate has a pointer, is the
> "size"
> > going to be size of the structure itself only, or should we also include
> the
> > memory block that pointer points to?
> >
> > Thanks,
> > Lin
>
> The size is the number of ocaml words in the structure itself. The
> pointer then points outside the ocaml heap to some C memory allocated by
> malloc(). You should account for that size in the used/max pair.
>
> Thank you so much for the reply.
So when we free the memory, what do we do with the block that pointer points
to? Free it in the 'finalization function' associated to 'ops'?

Best,
Lin


> MfG
>         Goswin
>



-- 
- lyn H

[-- Attachment #2: Type: text/html, Size: 1691 bytes --]

  reply	other threads:[~2010-05-18 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17 18:00 lyn HONG
2010-05-18  6:58 ` [Caml-list] " Goswin von Brederlow
2010-05-18 14:58   ` lyn HONG [this message]
2010-05-18 17:33     ` Goswin von Brederlow
2010-05-20 22:04 ` Richard Jones

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=AANLkTimvPmK_QGMlfNt578bxCknDk7ZprA0iNoolC91x@mail.gmail.com \
    --to=lynxiamen@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /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).