aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/alloc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f7544ab0b7c..f19ca3fb24c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -98,6 +98,9 @@ int pureptr;
98/* If nonzero, this is a warning delivered by malloc and not yet displayed. */ 98/* If nonzero, this is a warning delivered by malloc and not yet displayed. */
99char *pending_malloc_warning; 99char *pending_malloc_warning;
100 100
101/* Pre-computed signal argument for use when memory is exhausted. */
102static Lisp_Object memory_signal_data;
103
101/* Maximum amount of C stack to save when a GC happens. */ 104/* Maximum amount of C stack to save when a GC happens. */
102 105
103#ifndef MAX_SAVE_STACK 106#ifndef MAX_SAVE_STACK
@@ -148,7 +151,10 @@ display_malloc_warning ()
148/* Called if malloc returns zero */ 151/* Called if malloc returns zero */
149memory_full () 152memory_full ()
150{ 153{
151 error ("Memory exhausted"); 154 /* This used to call error, but if we've run out of memory, we could get
155 infinite recursion trying to build the string. */
156 while (1)
157 Fsignal (Qerror, memory_signal_data);
152} 158}
153 159
154/* like malloc routines but check for no memory and block interrupt input. */ 160/* like malloc routines but check for no memory and block interrupt input. */
@@ -2216,6 +2222,11 @@ The size is counted as the number of bytes occupied,\n\
2216which includes both saved text and other data."); 2222which includes both saved text and other data.");
2217 undo_strong_limit = 30000; 2223 undo_strong_limit = 30000;
2218 2224
2225 /* We build this in advance because if we wait until we need it, we might
2226 not be able to allocate the memory to hold it. */
2227 memory_signal_data = Fcons (build_string ("Memory exhausted"), Qnil);
2228 staticpro (&memory_signal_data);
2229
2219 defsubr (&Scons); 2230 defsubr (&Scons);
2220 defsubr (&Slist); 2231 defsubr (&Slist);
2221 defsubr (&Svector); 2232 defsubr (&Svector);