Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
allocating memory for c-structures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-26 (18:52)
From: micha <micha-1@f...>
Subject: Re: [Caml-list] allocating memory for c-structures
thanks for all the answers.

Richard Jones schrieb:
> That seems like it'll work for "opaque" C objects, but it's a bit of a
> hack.  The immediate issues I can think are:
> (a) Pointers in the C code which point at the object will not be
> "counted" by the GC, and so the object may be collected while there
> are still C pointers around.  This is easily avoided in OCaml, but
> read chapter 18 of the manual carefully.
that's true; for linked data structures it would not work (except all
would be allocated this way)

> Actually, while I was writing the above, it struck me that perhaps
> you're talking about some sort of marshalling system?  OCaml supports
> its own marshalling format, and a rich variety of other external forms
> of marshalling.
ah no, I just thought that it would be another way to handle external
What I didn't realize was, that the gc moves pointers around...