# HG changeset patch # User Stefan Monnier # Date 1104870161 0 # Node ID 1678d14c41098c8a4aa3d463f3d924e5dd1d054f # Parent 183547001aeefd392f7f55ce926974e932398576 (refill_memory_reserve): Move. (emacs_blocked_free, emacs_blocked_malloc, emacs_blocked_realloc) (reset_malloc_hooks, uninterrupt_malloc) [SYNC_INPUT]: Don't define. diff -r 183547001aee -r 1678d14c4109 src/ChangeLog --- a/src/ChangeLog Tue Jan 04 19:51:00 2005 +0000 +++ b/src/ChangeLog Tue Jan 04 20:22:41 2005 +0000 @@ -1,3 +1,9 @@ +2005-01-04 Stefan Monnier + + * alloc.c (refill_memory_reserve): Move. + (emacs_blocked_free, emacs_blocked_malloc, emacs_blocked_realloc) + (reset_malloc_hooks, uninterrupt_malloc) [SYNC_INPUT]: Don't define. + 2005-01-03 Richard M. Stallman * window.c (window_scroll_pixel_based): Don't correct preserve_y diff -r 183547001aee -r 1678d14c4109 src/alloc.c --- a/src/alloc.c Tue Jan 04 19:51:00 2005 +0000 +++ b/src/alloc.c Tue Jan 04 20:22:41 2005 +0000 @@ -103,7 +103,7 @@ 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. */ @@ -1113,17 +1113,34 @@ } +#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 @@ } -/* 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 @@ __realloc_hook = emacs_blocked_realloc; } +#endif /* not SYNC_INPUT */ #endif /* not SYSTEM_MALLOC */