diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/src/alloc.c b/src/alloc.c index 3861d87c3d8..ff0c3d46d44 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -548,6 +548,21 @@ DEFUN ("memory-full-p", Fmemory_full_p, Smemory_full_p, 0, 0, 0, | |||
| 548 | return (spare_memory ? Qnil : Qt); | 548 | return (spare_memory ? Qnil : Qt); |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | /* If we released our reserve (due to running out of memory), | ||
| 552 | and we have a fair amount free once again, | ||
| 553 | try to set aside another reserve in case we run out once more. | ||
| 554 | |||
| 555 | This is called when a relocatable block is freed in ralloc.c. */ | ||
| 556 | |||
| 557 | void | ||
| 558 | refill_memory_reserve () | ||
| 559 | { | ||
| 560 | #ifndef SYSTEM_MALLOC | ||
| 561 | if (spare_memory == 0) | ||
| 562 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); | ||
| 563 | #endif | ||
| 564 | } | ||
| 565 | |||
| 551 | /* Called if we can't allocate relocatable space for a buffer. */ | 566 | /* Called if we can't allocate relocatable space for a buffer. */ |
| 552 | 567 | ||
| 553 | void | 568 | void |
| @@ -1135,20 +1150,6 @@ allocate_buffer () | |||
| 1135 | 1150 | ||
| 1136 | #ifndef SYSTEM_MALLOC | 1151 | #ifndef SYSTEM_MALLOC |
| 1137 | 1152 | ||
| 1138 | /* If we released our reserve (due to running out of memory), | ||
| 1139 | and we have a fair amount free once again, | ||
| 1140 | try to set aside another reserve in case we run out once more. | ||
| 1141 | |||
| 1142 | This is called when a relocatable block is freed in ralloc.c. */ | ||
| 1143 | |||
| 1144 | void | ||
| 1145 | refill_memory_reserve () | ||
| 1146 | { | ||
| 1147 | if (spare_memory == 0) | ||
| 1148 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); | ||
| 1149 | } | ||
| 1150 | |||
| 1151 | |||
| 1152 | /* Arranging to disable input signals while we're in malloc. | 1153 | /* Arranging to disable input signals while we're in malloc. |
| 1153 | 1154 | ||
| 1154 | This only works with GNU malloc. To help out systems which can't | 1155 | This only works with GNU malloc. To help out systems which can't |
| @@ -1162,20 +1163,21 @@ refill_memory_reserve () | |||
| 1162 | #ifndef SYNC_INPUT | 1163 | #ifndef SYNC_INPUT |
| 1163 | 1164 | ||
| 1164 | #ifndef DOUG_LEA_MALLOC | 1165 | #ifndef DOUG_LEA_MALLOC |
| 1165 | extern void * (*__malloc_hook) P_ ((size_t)); | 1166 | extern void * (*__malloc_hook) P_ ((size_t, const void *)); |
| 1166 | extern void * (*__realloc_hook) P_ ((void *, size_t)); | 1167 | extern void * (*__realloc_hook) P_ ((void *, size_t, const void *)); |
| 1167 | extern void (*__free_hook) P_ ((void *)); | 1168 | extern void (*__free_hook) P_ ((void *, const void *)); |
| 1168 | /* Else declared in malloc.h, perhaps with an extra arg. */ | 1169 | /* Else declared in malloc.h, perhaps with an extra arg. */ |
| 1169 | #endif /* DOUG_LEA_MALLOC */ | 1170 | #endif /* DOUG_LEA_MALLOC */ |
| 1170 | static void * (*old_malloc_hook) (); | 1171 | static void * (*old_malloc_hook) P_ ((size_t, const void *)); |
| 1171 | static void * (*old_realloc_hook) (); | 1172 | static void * (*old_realloc_hook) P_ ((void *, size_t, const void*)); |
| 1172 | static void (*old_free_hook) (); | 1173 | static void (*old_free_hook) P_ ((void*, const void*)); |
| 1173 | 1174 | ||
| 1174 | /* This function is used as the hook for free to call. */ | 1175 | /* This function is used as the hook for free to call. */ |
| 1175 | 1176 | ||
| 1176 | static void | 1177 | static void |
| 1177 | emacs_blocked_free (ptr) | 1178 | emacs_blocked_free (ptr, ptr2) |
| 1178 | void *ptr; | 1179 | void *ptr; |
| 1180 | const void *ptr2; | ||
| 1179 | { | 1181 | { |
| 1180 | BLOCK_INPUT_ALLOC; | 1182 | BLOCK_INPUT_ALLOC; |
| 1181 | 1183 | ||
| @@ -1222,8 +1224,9 @@ emacs_blocked_free (ptr) | |||
| 1222 | /* This function is the malloc hook that Emacs uses. */ | 1224 | /* This function is the malloc hook that Emacs uses. */ |
| 1223 | 1225 | ||
| 1224 | static void * | 1226 | static void * |
| 1225 | emacs_blocked_malloc (size) | 1227 | emacs_blocked_malloc (size, ptr) |
| 1226 | size_t size; | 1228 | size_t size; |
| 1229 | const void *ptr; | ||
| 1227 | { | 1230 | { |
| 1228 | void *value; | 1231 | void *value; |
| 1229 | 1232 | ||
| @@ -1269,9 +1272,10 @@ emacs_blocked_malloc (size) | |||
| 1269 | /* This function is the realloc hook that Emacs uses. */ | 1272 | /* This function is the realloc hook that Emacs uses. */ |
| 1270 | 1273 | ||
| 1271 | static void * | 1274 | static void * |
| 1272 | emacs_blocked_realloc (ptr, size) | 1275 | emacs_blocked_realloc (ptr, size, ptr2) |
| 1273 | void *ptr; | 1276 | void *ptr; |
| 1274 | size_t size; | 1277 | size_t size; |
| 1278 | const void *ptr2; | ||
| 1275 | { | 1279 | { |
| 1276 | void *value; | 1280 | void *value; |
| 1277 | 1281 | ||