Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Garbage collection and a reference counting library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] Garbage collection and a reference counting library
On Thu, Dec 11, 2003 at 04:14:45PM +0100, Jean-Christophe Filliatre wrote:

>  > static value
>  > Val_voidptr (void *ptr)
>  > {
>  >   value rv = alloc (1, Abstract_tag); /* XXX Is this correct? */
>  >   Field(rv, 0) = (value) ptr;
>  >   return rv;
>  > }
> 
> A first remark: to be GC-friendly you have to use CAMLlocal1 to
> declare rv and CAMLreturn instead of return.

Although, it isn't necessary in this situation.  GC only happens on
allocation, so the value 'rv' never has an opportunity to change, so
there is nothing wrong with this function.

But, if you're not sure, it is better to err being too safe rather than
not being safe enough.  Performance is the only issue.

Dave

-------------------
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