Browse thread
[Caml-list] Question about register_global_root
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jerome Simeon <simeon@r...> |
| Subject: | Re: [Caml-list] Question about register_global_root |
On Sun, 2003-06-01 at 15:53, Damien Doligez wrote: > On Sunday, June 1, 2003, at 12:50 PM, Maas-Maarten Zeeman wrote: > > > Chris Hecker wrote: > > > >> > >>> handlers = (value *) malloc(sizeof(value)); > >>> register_global_root(handlers); > >> > >> > >> Shouldn't you init *handlers to Val_unit before calling > >> register_global_root() as well? > > > > The manual explicitly tells that register_global_root should be called > > before any valid value is stored in it for the first time, like > > Val_unit. See Rule 4 of Interfacing C with Objective Caml in the > > manual. > > > > So I think it is ok the way it is implemented. > > I'm afraid Chris is right and the manual is wrong. > Us poor developers could use a little improvement in the doc in this area. Some additional example doing this feature in the doc would help... - Jerome > You can store Val_unit before you call register_global_root, because > Val_unit is not a pointer into the Caml heap. > You must store a valid value before the first allocation that follows > register_global_root. > You can store an allocated value (a pointer into the Caml heap) before > or after calling register_global_root, but it must be after the last > allocation that precedes register_global_root, and before the first > allocation that succeeds it. > > At any rate, storing Val_unit before you call register_global_root is > safe and does not cost much CPU time. > > -- Damien -- Jerome Simeon <simeon@research.bell-labs.com> Lucent Technologies ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners