[Gc] GC_register_disappearing_link

MenTaLguY mental at rydia.net
Mon Nov 15 10:04:17 PST 2004

On Sun, 14 Nov 2004, Hans Van den Eynden wrote:

> Is this function used in
> GC_general_register_disappearing_link(GC_PTR * link, GC_PTR obj) and
> should we not use GC_register_disappearing_link GC_PROTO((GC_PTR * /*
> link */)); ?

GC_register_disappearing_link(&foo) is roughly equivalent to
GC_general_register_disappearing_link(&foo, foo).

The latter function is more general and can, for example, be used to avoid
finalization cycles:  given an object in doubly-linked list of objects
with finalizers, you could break one of the links before finalization:

 GC_general_register_disappearing_link(&bar->prev, bar);

Admittedly, there are probably better approaches for writing such objects
which avoid the need to do this (e.g. splitting the portion that needs
finalization into a separate object).


More information about the Gc mailing list