diff options
| author | Stefan Monnier | 2005-01-04 20:22:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-01-04 20:22:41 +0000 |
| commit | 026cdede8576e1cb571b0674e4892a3d6a507fb6 (patch) | |
| tree | 7ebab5135a41cd052e40b08cd4082cc24ea9ceb5 /src/alloc.c | |
| parent | a4338f5175a7eeefa3d0eb52da9a2916d073d4fd (diff) | |
| download | emacs-026cdede8576e1cb571b0674e4892a3d6a507fb6.tar.gz emacs-026cdede8576e1cb571b0674e4892a3d6a507fb6.zip | |
(refill_memory_reserve): Move.
(emacs_blocked_free, emacs_blocked_malloc, emacs_blocked_realloc)
(reset_malloc_hooks, uninterrupt_malloc) [SYNC_INPUT]: Don't define.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/alloc.c b/src/alloc.c index a1ba6dfc513..3723f9ea872 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -103,7 +103,7 @@ extern __malloc_size_t __malloc_extra_blocks; | |||
| 103 | that the backend handles concurrent access to malloc within its own threads | 103 | that the backend handles concurrent access to malloc within its own threads |
| 104 | but Emacs code running in the main thread is not included in that control). | 104 | but Emacs code running in the main thread is not included in that control). |
| 105 | 105 | ||
| 106 | When UNBLOCK_INPUT is called, revoke_input_signal may be called. If this | 106 | When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this |
| 107 | happens in one of the backend threads we will have two threads that tries | 107 | happens in one of the backend threads we will have two threads that tries |
| 108 | to run Emacs code at once, and the code is not prepared for that. | 108 | to run Emacs code at once, and the code is not prepared for that. |
| 109 | To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ | 109 | To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ |
| @@ -1113,17 +1113,34 @@ allocate_buffer () | |||
| 1113 | } | 1113 | } |
| 1114 | 1114 | ||
| 1115 | 1115 | ||
| 1116 | #ifndef SYSTEM_MALLOC | ||
| 1117 | |||
| 1118 | /* If we released our reserve (due to running out of memory), | ||
| 1119 | and we have a fair amount free once again, | ||
| 1120 | try to set aside another reserve in case we run out once more. | ||
| 1121 | |||
| 1122 | This is called when a relocatable block is freed in ralloc.c. */ | ||
| 1123 | |||
| 1124 | void | ||
| 1125 | refill_memory_reserve () | ||
| 1126 | { | ||
| 1127 | if (spare_memory == 0) | ||
| 1128 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | |||
| 1116 | /* Arranging to disable input signals while we're in malloc. | 1132 | /* Arranging to disable input signals while we're in malloc. |
| 1117 | 1133 | ||
| 1118 | This only works with GNU malloc. To help out systems which can't | 1134 | This only works with GNU malloc. To help out systems which can't |
| 1119 | use GNU malloc, all the calls to malloc, realloc, and free | 1135 | use GNU malloc, all the calls to malloc, realloc, and free |
| 1120 | elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT | 1136 | elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT |
| 1121 | pairs; unfortunately, we have no idea what C library functions | 1137 | pair; unfortunately, we have no idea what C library functions |
| 1122 | might call malloc, so we can't really protect them unless you're | 1138 | might call malloc, so we can't really protect them unless you're |
| 1123 | using GNU malloc. Fortunately, most of the major operating systems | 1139 | using GNU malloc. Fortunately, most of the major operating systems |
| 1124 | can use GNU malloc. */ | 1140 | can use GNU malloc. */ |
| 1125 | 1141 | ||
| 1126 | #ifndef SYSTEM_MALLOC | 1142 | #ifndef SYNC_INPUT |
| 1143 | |||
| 1127 | #ifndef DOUG_LEA_MALLOC | 1144 | #ifndef DOUG_LEA_MALLOC |
| 1128 | extern void * (*__malloc_hook) P_ ((size_t)); | 1145 | extern void * (*__malloc_hook) P_ ((size_t)); |
| 1129 | extern void * (*__realloc_hook) P_ ((void *, size_t)); | 1146 | extern void * (*__realloc_hook) P_ ((void *, size_t)); |
| @@ -1182,20 +1199,6 @@ emacs_blocked_free (ptr) | |||
| 1182 | } | 1199 | } |
| 1183 | 1200 | ||
| 1184 | 1201 | ||
| 1185 | /* If we released our reserve (due to running out of memory), | ||
| 1186 | and we have a fair amount free once again, | ||
| 1187 | try to set aside another reserve in case we run out once more. | ||
| 1188 | |||
| 1189 | This is called when a relocatable block is freed in ralloc.c. */ | ||
| 1190 | |||
| 1191 | void | ||
| 1192 | refill_memory_reserve () | ||
| 1193 | { | ||
| 1194 | if (spare_memory == 0) | ||
| 1195 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | |||
| 1199 | /* This function is the malloc hook that Emacs uses. */ | 1202 | /* This function is the malloc hook that Emacs uses. */ |
| 1200 | 1203 | ||
| 1201 | static void * | 1204 | static void * |
| @@ -1347,6 +1350,7 @@ uninterrupt_malloc () | |||
| 1347 | __realloc_hook = emacs_blocked_realloc; | 1350 | __realloc_hook = emacs_blocked_realloc; |
| 1348 | } | 1351 | } |
| 1349 | 1352 | ||
| 1353 | #endif /* not SYNC_INPUT */ | ||
| 1350 | #endif /* not SYSTEM_MALLOC */ | 1354 | #endif /* not SYSTEM_MALLOC */ |
| 1351 | 1355 | ||
| 1352 | 1356 | ||