Browse thread
GC with C issues
[
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: | 2005-02-03 (12:52) |
From: | Damien Doligez <damien.doligez@i...> |
Subject: | Re: [Caml-list] GC with C issues |
On Feb 3, 2005, at 12:31, ronniec95@lineone.net wrote: >> Field (retVal, 0) = (value) x; > > Hmm... I thought I was only supposed to do that when using > alloc_small/alloc_shr interface? However using your method does work in > this small example though I'm worried about if something unexpected > will > happen in more 'real-life' code... Since retVal has the "Abstract" tag, its contents is none of the GC's business, so you don't need to use Store_field to tell it about assignments. On the other hand, depending on the bit-pattern of (the value of) x, you might crash the GC if you use Store_field. In this case, x is an aligned pointer outside the heap, so you're safe either way. But the proper way is to store directly with Field. If you want to be pedantic, it's not really a field but a bunch of bytes so the even more proper way is to write: * (someObject *) Bp_val (retVal) = x; -- Damien