[Gc] Is GC_init callable multiple times?

Hans Aberg haberg-1 at telia.com
Sat Mar 3 00:34:09 PST 2012

Some OO languages have special operations to ensure that.


On 3 Mar 2012, at 08:24, Alex wrote:

> Hi Ivan,
> OK, sounds good; in my case, it's easy to ensure that calls to
> GC_init() are synchronized, so that shouldn't be problematic.
> Thanks!
> Regards,
> Alex
> On Sat, Mar 3, 2012 at 8:22 AM, Ivan Maidanski <ivmai at mail.ru> wrote:
>> Hi Alex,
>> Calling GC_init second time (from the same thread) is just a no-op (although, this is not documented). (But concurrent GC_init calls from 2 threads might not work correctly.)
>> Regards.
>> 02 03 2012, 00:05 Alex <xtzgzorex at gmail.com>:
>>> Hi,
>>> Is the GC_init() function callable multiple times? In my case, I'm
>>> wrapping libgc in a class in an OO language, so it is easiest to
>>> simply call GC_init() in the constructor for said class. This means
>>> that it may well be called multiple times, however. Looking at the
>>> GC_init() and GC_init_inner() implementations in misc.c suggests that
>>> at least some sanity checks are done to ensure double-initialization
>>> doesn't happen even if GC_init() is called multiple times. However,
>>> this behavior doesn't seem to be documented anywhere, so I'm unsure
>>> whether calling GC_init() multiple times is considered sane and is
>>> part of the interface?
>>> Thanks in advance,
>>> Alex

More information about the Gc mailing list