Version française
Home     About     Download     Resources     Contact us    
Browse thread
What should the "size" in "caml_alloc_custom" be?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: lyn HONG <lynxiamen@g...>
Subject: Re: [Caml-list] What should the "size" in "caml_alloc_custom" be?
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