Mercurial > emacs
comparison src/alloc.c @ 46305:fed6b815dbeb
(Vmemory_full): New variable.
(Vmemory_signal_data): Renamed from memory_signal_data. Uses changed.
(syms_of_alloc): Defvar them.
(memory_full, buffer_memory_full): Set Vmemory_full.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Thu, 11 Jul 2002 17:44:22 +0000 |
| parents | 1fb8f75062c6 |
| children | 40db0673e6f0 |
comparison
equal
deleted
inserted
replaced
| 46304:76246741e5c2 | 46305:fed6b815dbeb |
|---|---|
| 179 | 179 |
| 180 /* Non-nil means defun should do purecopy on the function definition. */ | 180 /* Non-nil means defun should do purecopy on the function definition. */ |
| 181 | 181 |
| 182 Lisp_Object Vpurify_flag; | 182 Lisp_Object Vpurify_flag; |
| 183 | 183 |
| 184 /* Non-nil means we are handling a memory-full error. */ | |
| 185 | |
| 186 Lisp_Object Vmemory_full; | |
| 187 | |
| 184 #ifndef HAVE_SHM | 188 #ifndef HAVE_SHM |
| 185 | 189 |
| 186 /* Force it into data space! */ | 190 /* Force it into data space! */ |
| 187 | 191 |
| 188 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {0,}; | 192 EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {0,}; |
| 222 | 226 |
| 223 char *pending_malloc_warning; | 227 char *pending_malloc_warning; |
| 224 | 228 |
| 225 /* Pre-computed signal argument for use when memory is exhausted. */ | 229 /* Pre-computed signal argument for use when memory is exhausted. */ |
| 226 | 230 |
| 227 Lisp_Object memory_signal_data; | 231 Lisp_Object Vmemory_signal_data; |
| 228 | 232 |
| 229 /* Maximum amount of C stack to save when a GC happens. */ | 233 /* Maximum amount of C stack to save when a GC happens. */ |
| 230 | 234 |
| 231 #ifndef MAX_SAVE_STACK | 235 #ifndef MAX_SAVE_STACK |
| 232 #define MAX_SAVE_STACK 16000 | 236 #define MAX_SAVE_STACK 16000 |
| 467 /* Called if malloc returns zero. */ | 471 /* Called if malloc returns zero. */ |
| 468 | 472 |
| 469 void | 473 void |
| 470 memory_full () | 474 memory_full () |
| 471 { | 475 { |
| 476 Vmemory_full = Qt; | |
| 477 | |
| 472 #ifndef SYSTEM_MALLOC | 478 #ifndef SYSTEM_MALLOC |
| 473 bytes_used_when_full = BYTES_USED; | 479 bytes_used_when_full = BYTES_USED; |
| 474 #endif | 480 #endif |
| 475 | 481 |
| 476 /* The first time we get here, free the spare memory. */ | 482 /* The first time we get here, free the spare memory. */ |
| 481 } | 487 } |
| 482 | 488 |
| 483 /* This used to call error, but if we've run out of memory, we could | 489 /* This used to call error, but if we've run out of memory, we could |
| 484 get infinite recursion trying to build the string. */ | 490 get infinite recursion trying to build the string. */ |
| 485 while (1) | 491 while (1) |
| 486 Fsignal (Qnil, memory_signal_data); | 492 Fsignal (Qnil, Vmemory_signal_data); |
| 487 } | 493 } |
| 488 | 494 |
| 489 | 495 |
| 490 /* Called if we can't allocate relocatable space for a buffer. */ | 496 /* Called if we can't allocate relocatable space for a buffer. */ |
| 491 | 497 |
| 501 | 507 |
| 502 #ifndef REL_ALLOC | 508 #ifndef REL_ALLOC |
| 503 memory_full (); | 509 memory_full (); |
| 504 #endif | 510 #endif |
| 505 | 511 |
| 512 Vmemory_full = Qt; | |
| 513 | |
| 506 /* This used to call error, but if we've run out of memory, we could | 514 /* This used to call error, but if we've run out of memory, we could |
| 507 get infinite recursion trying to build the string. */ | 515 get infinite recursion trying to build the string. */ |
| 508 while (1) | 516 while (1) |
| 509 Fsignal (Qerror, memory_signal_data); | 517 Fsignal (Qnil, Vmemory_signal_data); |
| 510 } | 518 } |
| 511 | 519 |
| 512 | 520 |
| 513 /* Like malloc but check for no memory and block interrupt input.. */ | 521 /* Like malloc but check for no memory and block interrupt input.. */ |
| 514 | 522 |
| 5539 doc: /* Hook run after garbage collection has finished. */); | 5547 doc: /* Hook run after garbage collection has finished. */); |
| 5540 Vpost_gc_hook = Qnil; | 5548 Vpost_gc_hook = Qnil; |
| 5541 Qpost_gc_hook = intern ("post-gc-hook"); | 5549 Qpost_gc_hook = intern ("post-gc-hook"); |
| 5542 staticpro (&Qpost_gc_hook); | 5550 staticpro (&Qpost_gc_hook); |
| 5543 | 5551 |
| 5552 DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data, | |
| 5553 doc: /* Precomputed `signal' argument for memory-full error. */); | |
| 5544 /* We build this in advance because if we wait until we need it, we might | 5554 /* We build this in advance because if we wait until we need it, we might |
| 5545 not be able to allocate the memory to hold it. */ | 5555 not be able to allocate the memory to hold it. */ |
| 5546 memory_signal_data | 5556 Vmemory_signal_data |
| 5547 = Fcons (Qerror, Fcons (build_string ("Memory exhausted--use M-x save-some-buffers RET"), Qnil)); | 5557 = list2 (Qerror, |
| 5548 staticpro (&memory_signal_data); | 5558 build_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs")); |
| 5559 | |
| 5560 DEFVAR_LISP ("memory-full", &Vmemory_full, | |
| 5561 doc: /* Non-nil means we are handling a memory-full error. */); | |
| 5562 Vmemory_full = Qnil; | |
| 5549 | 5563 |
| 5550 staticpro (&Qgc_cons_threshold); | 5564 staticpro (&Qgc_cons_threshold); |
| 5551 Qgc_cons_threshold = intern ("gc-cons-threshold"); | 5565 Qgc_cons_threshold = intern ("gc-cons-threshold"); |
| 5552 | 5566 |
| 5553 staticpro (&Qchar_table_extra_slots); | 5567 staticpro (&Qchar_table_extra_slots); |
