Issue #186 (bdwgc).
* include/gc.h (GC_is_init_called): New API function declaration.
* misc.c (GC_is_init_called): New API function definition.
* tests/test.c (check_heap_stats): Add a test that GC is initialized.
/* from the main program instead. */
GC_API void GC_CALL GC_init(void);
+/* Returns non-zero (TRUE) if and only if the collector is initialized */
+/* (or, at least, the initialization is in progress). */
+GC_API int GC_CALL GC_is_init_called(void);
+
/* Perform the collector shutdown. (E.g. dispose critical sections on */
/* Win32 target.) A duplicate invocation is a no-op. GC_INIT should */
/* not be called after the shutdown. See also GC_win32_free_heap(). */
GC_INNER GC_bool GC_is_initialized = FALSE;
+GC_API int GC_CALL GC_is_init_called(void)
+{
+ return GC_is_initialized;
+}
+
#if (defined(MSWIN32) || defined(MSWINCE)) && defined(THREADS)
GC_INNER CRITICAL_SECTION GC_write_cs;
#endif
# endif
unsigned obj_count = 0;
+ if (!GC_is_init_called()) {
+ GC_printf("GC should be initialized!\n");
+ FAIL;
+ }
# ifdef VERY_SMALL_CONFIG
/* The upper bounds are a guess, which has been empirically */
/* adjusted. On low end uniprocessors with incremental GC */