From 026cdede8576e1cb571b0674e4892a3d6a507fb6 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 4 Jan 2005 20:22:41 +0000 Subject: (refill_memory_reserve): Move. (emacs_blocked_free, emacs_blocked_malloc, emacs_blocked_realloc) (reset_malloc_hooks, uninterrupt_malloc) [SYNC_INPUT]: Don't define. --- src/alloc.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index a1ba6dfc51..3723f9ea87 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -103,7 +103,7 @@ extern __malloc_size_t __malloc_extra_blocks; that the backend handles concurrent access to malloc within its own threads but Emacs code running in the main thread is not included in that control). - When UNBLOCK_INPUT is called, revoke_input_signal may be called. If this + When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this happens in one of the backend threads we will have two threads that tries to run Emacs code at once, and the code is not prepared for that. To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ @@ -1112,18 +1112,35 @@ allocate_buffer () return b; } + +#ifndef SYSTEM_MALLOC + +/* If we released our reserve (due to running out of memory), + and we have a fair amount free once again, + try to set aside another reserve in case we run out once more. + + This is called when a relocatable block is freed in ralloc.c. */ + +void +refill_memory_reserve () +{ + if (spare_memory == 0) + spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); +} + /* Arranging to disable input signals while we're in malloc. This only works with GNU malloc. To help out systems which can't use GNU malloc, all the calls to malloc, realloc, and free elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT - pairs; unfortunately, we have no idea what C library functions + pair; unfortunately, we have no idea what C library functions might call malloc, so we can't really protect them unless you're using GNU malloc. Fortunately, most of the major operating systems can use GNU malloc. */ -#ifndef SYSTEM_MALLOC +#ifndef SYNC_INPUT + #ifndef DOUG_LEA_MALLOC extern void * (*__malloc_hook) P_ ((size_t)); extern void * (*__realloc_hook) P_ ((void *, size_t)); @@ -1182,20 +1199,6 @@ emacs_blocked_free (ptr) } -/* If we released our reserve (due to running out of memory), - and we have a fair amount free once again, - try to set aside another reserve in case we run out once more. - - This is called when a relocatable block is freed in ralloc.c. */ - -void -refill_memory_reserve () -{ - if (spare_memory == 0) - spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); -} - - /* This function is the malloc hook that Emacs uses. */ static void * @@ -1347,6 +1350,7 @@ uninterrupt_malloc () __realloc_hook = emacs_blocked_realloc; } +#endif /* not SYNC_INPUT */ #endif /* not SYSTEM_MALLOC */ -- cgit v1.2.3