Mercurial > emacs
comparison src/alloc.c @ 83383:2a679c81f552
Merged from miles@gnu.org--gnu-2005 (patch 118-132, 551-577)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-551
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-552
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-553
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-554
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-555
Remove CVS keywords from newsticker files
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-556
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-557
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-558
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-559
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-560
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-561
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-562
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-563
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-564
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-565
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-566
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-567
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-568
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-569
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-570
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-571
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-572
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-573
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-575
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-576
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-577
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-118
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-119
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-120
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-121
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-122
Update from CVS: lisp/mm-url.el (mm-url-decode-entities): Fix regexp.
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-123
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-124
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-125
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-126
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-127
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-128
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-129
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-130
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-131
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-132
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-423
| author | Karoly Lorentey <lorentey@elte.hu> |
|---|---|
| date | Sun, 09 Oct 2005 20:00:17 +0000 |
| parents | 532e0a9335a9 5159ee08b219 |
| children | 693e794b57bf |
comparison
equal
deleted
inserted
replaced
| 83382:7a3090aca393 | 83383:2a679c81f552 |
|---|---|
| 546 () | 546 () |
| 547 { | 547 { |
| 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 |
| 554 buffer_memory_full () | 569 buffer_memory_full () |
| 555 { | 570 { |
| 1133 } | 1148 } |
| 1134 | 1149 |
| 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 |
| 1155 use GNU malloc, all the calls to malloc, realloc, and free | 1156 use GNU malloc, all the calls to malloc, realloc, and free |
| 1156 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT | 1157 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT |
| 1160 can use GNU malloc. */ | 1161 can use GNU malloc. */ |
| 1161 | 1162 |
| 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 |
| 1182 #ifdef GC_MALLOC_CHECK | 1184 #ifdef GC_MALLOC_CHECK |
| 1183 if (ptr) | 1185 if (ptr) |
| 1220 | 1222 |
| 1221 | 1223 |
| 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 |
| 1230 BLOCK_INPUT_ALLOC; | 1233 BLOCK_INPUT_ALLOC; |
| 1231 __malloc_hook = old_malloc_hook; | 1234 __malloc_hook = old_malloc_hook; |
| 1267 | 1270 |
| 1268 | 1271 |
| 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 |
| 1278 BLOCK_INPUT_ALLOC; | 1282 BLOCK_INPUT_ALLOC; |
| 1279 __realloc_hook = old_realloc_hook; | 1283 __realloc_hook = old_realloc_hook; |
