comparison src/alloc.c @ 90237:aa89c814f853

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-88 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 569-579) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 129-132) - Update from CVS - Merge from emacs--cvs-trunk--0
author Miles Bader <miles@gnu.org>
date Fri, 07 Oct 2005 07:15:40 +0000
parents 890cc78a5a24 5159ee08b219
children 7beb78bc1f8e
comparison
equal deleted inserted replaced
90236:7871ecd1281b 90237:aa89c814f853
545 () 545 ()
546 { 546 {
547 return (spare_memory ? Qnil : Qt); 547 return (spare_memory ? Qnil : Qt);
548 } 548 }
549 549
550 /* If we released our reserve (due to running out of memory),
551 and we have a fair amount free once again,
552 try to set aside another reserve in case we run out once more.
553
554 This is called when a relocatable block is freed in ralloc.c. */
555
556 void
557 refill_memory_reserve ()
558 {
559 #ifndef SYSTEM_MALLOC
560 if (spare_memory == 0)
561 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
562 #endif
563 }
564
550 /* Called if we can't allocate relocatable space for a buffer. */ 565 /* Called if we can't allocate relocatable space for a buffer. */
551 566
552 void 567 void
553 buffer_memory_full () 568 buffer_memory_full ()
554 { 569 {
1132 } 1147 }
1133 1148
1134 1149
1135 #ifndef SYSTEM_MALLOC 1150 #ifndef SYSTEM_MALLOC
1136 1151
1137 /* If we released our reserve (due to running out of memory),
1138 and we have a fair amount free once again,
1139 try to set aside another reserve in case we run out once more.
1140
1141 This is called when a relocatable block is freed in ralloc.c. */
1142
1143 void
1144 refill_memory_reserve ()
1145 {
1146 if (spare_memory == 0)
1147 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
1148 }
1149
1150
1151 /* Arranging to disable input signals while we're in malloc. 1152 /* Arranging to disable input signals while we're in malloc.
1152 1153
1153 This only works with GNU malloc. To help out systems which can't 1154 This only works with GNU malloc. To help out systems which can't
1154 use GNU malloc, all the calls to malloc, realloc, and free 1155 use GNU malloc, all the calls to malloc, realloc, and free
1155 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT 1156 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT
1159 can use GNU malloc. */ 1160 can use GNU malloc. */
1160 1161
1161 #ifndef SYNC_INPUT 1162 #ifndef SYNC_INPUT
1162 1163
1163 #ifndef DOUG_LEA_MALLOC 1164 #ifndef DOUG_LEA_MALLOC
1164 extern void * (*__malloc_hook) P_ ((size_t)); 1165 extern void * (*__malloc_hook) P_ ((size_t, const void *));
1165 extern void * (*__realloc_hook) P_ ((void *, size_t)); 1166 extern void * (*__realloc_hook) P_ ((void *, size_t, const void *));
1166 extern void (*__free_hook) P_ ((void *)); 1167 extern void (*__free_hook) P_ ((void *, const void *));
1167 /* Else declared in malloc.h, perhaps with an extra arg. */ 1168 /* Else declared in malloc.h, perhaps with an extra arg. */
1168 #endif /* DOUG_LEA_MALLOC */ 1169 #endif /* DOUG_LEA_MALLOC */
1169 static void * (*old_malloc_hook) (); 1170 static void * (*old_malloc_hook) P_ ((size_t, const void *));
1170 static void * (*old_realloc_hook) (); 1171 static void * (*old_realloc_hook) P_ ((void *, size_t, const void*));
1171 static void (*old_free_hook) (); 1172 static void (*old_free_hook) P_ ((void*, const void*));
1172 1173
1173 /* This function is used as the hook for free to call. */ 1174 /* This function is used as the hook for free to call. */
1174 1175
1175 static void 1176 static void
1176 emacs_blocked_free (ptr) 1177 emacs_blocked_free (ptr, ptr2)
1177 void *ptr; 1178 void *ptr;
1179 const void *ptr2;
1178 { 1180 {
1179 BLOCK_INPUT_ALLOC; 1181 BLOCK_INPUT_ALLOC;
1180 1182
1181 #ifdef GC_MALLOC_CHECK 1183 #ifdef GC_MALLOC_CHECK
1182 if (ptr) 1184 if (ptr)
1219 1221
1220 1222
1221 /* This function is the malloc hook that Emacs uses. */ 1223 /* This function is the malloc hook that Emacs uses. */
1222 1224
1223 static void * 1225 static void *
1224 emacs_blocked_malloc (size) 1226 emacs_blocked_malloc (size, ptr)
1225 size_t size; 1227 size_t size;
1228 const void *ptr;
1226 { 1229 {
1227 void *value; 1230 void *value;
1228 1231
1229 BLOCK_INPUT_ALLOC; 1232 BLOCK_INPUT_ALLOC;
1230 __malloc_hook = old_malloc_hook; 1233 __malloc_hook = old_malloc_hook;
1266 1269
1267 1270
1268 /* This function is the realloc hook that Emacs uses. */ 1271 /* This function is the realloc hook that Emacs uses. */
1269 1272
1270 static void * 1273 static void *
1271 emacs_blocked_realloc (ptr, size) 1274 emacs_blocked_realloc (ptr, size, ptr2)
1272 void *ptr; 1275 void *ptr;
1273 size_t size; 1276 size_t size;
1277 const void *ptr2;
1274 { 1278 {
1275 void *value; 1279 void *value;
1276 1280
1277 BLOCK_INPUT_ALLOC; 1281 BLOCK_INPUT_ALLOC;
1278 __realloc_hook = old_realloc_hook; 1282 __realloc_hook = old_realloc_hook;