aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm <[email protected]>2004-06-21 22:35:29 +0000
committerKim F. Storm <[email protected]>2004-06-21 22:35:29 +0000
commita9e6baccec3c32fba2de37fd40836e173e2b8f15 (patch)
tree6c6d064373d90c5c91bdf97a4c2ba324952ef0b1 /src
parent3d33d9939e186ff7d764e60c971c4c62ddcd95e6 (diff)
(SAFE_ALLOCA_LISP): New macro to allocate Lisp_Objects.
Temporarily inhibits GC if memory is xmalloc'ed, as the Lisp_Objects in that memory area are unknown to GC. Add comments.
Diffstat (limited to 'src')
-rw-r--r--src/lisp.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h
index dc78e52421..c6e585e086 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3256,6 +3256,8 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
#define USE_SAFE_ALLOCA \
int sa_count = SPECPDL_INDEX ()
+/* SAFE_ALLOCA allocates a simple buffer. */
+
#define SAFE_ALLOCA(buf, type, size) \
do { \
if ((size) < MAX_ALLOCA) \
@@ -3268,6 +3270,24 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
} \
} while (0)
+/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects.
+ Temporarily inhibits GC since that array is unknow to GC. */
+
+#define SAFE_ALLOCA_LISP(buf, size) \
+ do { \
+ if ((size) < MAX_ALLOCA) \
+ buf = (Lisp_Object *) alloca (size); \
+ else \
+ { \
+ buf = (Lisp_Object *) xmalloc (size); \
+ inhibit_garbage_collection(); \
+ record_unwind_protect (safe_alloca_unwind, \
+ make_save_value (buf, 0)); \
+ } \
+ } while (0)
+
+/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
+
#define SAFE_FREE(size) \
do { \
if ((size) >= MAX_ALLOCA) \