emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/lisp.h


From: Kim F . Storm
Subject: [Emacs-diffs] Changes to emacs/src/lisp.h
Date: Mon, 21 Jun 2004 17:55:59 -0400

Index: emacs/src/lisp.h
diff -c emacs/src/lisp.h:1.496 emacs/src/lisp.h:1.497
*** emacs/src/lisp.h:1.496      Sat May 29 16:18:41 2004
--- emacs/src/lisp.h    Mon Jun 21 21:51:18 2004
***************
*** 3246,3251 ****
--- 3246,3282 ----
         : Fcons ((el), (check)))))
  
  
+ /* SAFE_ALLOCA normally allocates memory on the stack, but if size is
+    larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack.  */
+ 
+ #define MAX_ALLOCA 16*1024
+ 
+ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
+ 
+ #define USE_SAFE_ALLOCA                       \
+   int sa_count = SPECPDL_INDEX ()
+ 
+ #define SAFE_ALLOCA(buf, type, size)                    \
+   do {                                                          \
+     if ((size) < MAX_ALLOCA)                            \
+       buf = (type) alloca (size);                       \
+     else                                                \
+       {                                                         \
+       buf = (type) xmalloc (size);                      \
+       record_unwind_protect (safe_alloca_unwind,        \
+                              make_save_value (buf, 0)); \
+       }                                                         \
+   } while (0)
+ 
+ #define SAFE_FREE(size)                       \
+   do {                                        \
+     if ((size) >= MAX_ALLOCA)         \
+       unbind_to (sa_count, Qnil);     \
+   } while (0)
+ 
+ 
+ 
+ 
  #endif /* EMACS_LISP_H */
  
  /* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e




reply via email to

[Prev in Thread] Current Thread [Next in Thread]