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: | Chris Hecker <checker@d...> |
| Subject: | Re: [Caml-list] Question about register_global_root |
>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. Yes, but you don't store immediately, you call the alloc_tuple: > handlers = (value *) malloc(sizeof(value)); > register_global_root(handlers); > *handlers = alloc_tuple(NUM_HANDLERS); If alloc_tuple has to collect, then the gc will scan *handlers but it is uninitialized data. If you called alloc_tuple above the register and stored it in a CAMLlocal variable, then just stuffed *handler immediately with that value after register I could see it working, but I don't see how the current code isn't a possible error. Maybe I'm misunderstanding how the GC works or something? Chris ------------------- 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