1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

* gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.

* 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.
This commit is contained in:
Mikael Djurfeldt 2002-12-10 20:25:26 +00:00
parent 3cdde9d667
commit 960c408c04
4 changed files with 14 additions and 4 deletions

View file

@ -101,6 +101,12 @@ static int scm_i_minyield_malloc;
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)
{
@ -116,8 +122,6 @@ scm_gc_init_malloc (void)
if (scm_mtrigger < 0)
scm_mtrigger = SCM_DEFAULT_INIT_MALLOC_LIMIT;
scm_i_plugin_mutex_init (&malloc_mutex, 0);
}
@ -132,7 +136,7 @@ scm_realloc (void *mem, size_t size)
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;