* gc-malloc.c (malloc_mutex): New mutex.
(scm_gc_malloc_prehistory): Initialize it.
(scm_realloc): Serialize call to realloc
(scm_calloc): Same for calloc.
Thanks to Wolfgang Jaehrling!
(Now we have to make sure all calls to malloc/realloc are made
through scm_malloc.)
* init.c (scm_init_guile_1): Call scm_gc_malloc_prehistory.
2002-12-10 Mikael Djurfeldt <mdj@kvast.blakulla.net>
+ * gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.
+
* gc-malloc.c (malloc_mutex): New mutex.
- (scm_gc_init_malloc): Initialize it.
+ (scm_gc_malloc_prehistory): Initialize it.
(scm_realloc): Serialize call to realloc
(scm_calloc): Same for calloc.
Thanks to Wolfgang Jaehrling!
(Now we have to make sure all calls to malloc/realloc are made
through scm_malloc.)
+ * init.c (scm_init_guile_1): Call scm_gc_malloc_prehistory.
+
* threads.c (really_launch): Release heap (to prevent deadlock).
(create_thread): Release heap before locking thread admin mutex.
static scm_t_mutex malloc_mutex;
+void
+scm_gc_malloc_prehistory ()
+{
+ scm_i_plugin_mutex_init (&malloc_mutex, 0);
+}
+
void
scm_gc_init_malloc (void)
{
if (scm_mtrigger < 0)
scm_mtrigger = SCM_DEFAULT_INIT_MALLOC_LIMIT;
-
- scm_i_plugin_mutex_init (&malloc_mutex, 0);
}
scm_i_plugin_mutex_lock (&malloc_mutex);
SCM_SYSCALL (ptr = realloc (mem, size));
- scm_i_plugin_mutex_lock (&malloc_mutex);
+ scm_i_plugin_mutex_unlock (&malloc_mutex);
if (ptr)
return ptr;
SCM_API void scm_gc_unregister_root (SCM *p);
SCM_API void scm_gc_register_roots (SCM *b, unsigned long n);
SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n);
+SCM_API void scm_gc_malloc_prehistory (void);
SCM_API int scm_init_storage (void);
SCM_API void *scm_get_stack_base (void);
SCM_API void scm_init_gc (void);
scm_block_gc = 1;
+ scm_gc_malloc_prehistory ();
scm_threads_prehistory ();
scm_ports_prehistory ();
scm_smob_prehistory ();