aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-06-22 13:57:18 +0000
committerKim F. Storm2004-06-22 13:57:18 +0000
commit5f5d6c621aadccb1ecb74e41f5c3c9267d55f928 (patch)
tree2a6852a4151f970eb2b842d4b8fd1426730df171 /src
parent7b4cd44a019f6dc8f6da54e23a1fbfb2354c721b (diff)
downloademacs-5f5d6c621aadccb1ecb74e41f5c3c9267d55f928.tar.gz
emacs-5f5d6c621aadccb1ecb74e41f5c3c9267d55f928.zip
(struct Lisp_Save_Value): New member dogc.
(SAFE_ALLOCA_LISP): Change second arg to number of elements. Set dogc member in Lisp_Save_Value object so it will be GC'ed. (SAFE_FREE_LISP): New macro.
Diffstat (limited to 'src')
-rw-r--r--src/lisp.h44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/lisp.h b/src/lisp.h
index c6e585e0863..bc55761c9dc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1199,7 +1199,10 @@ struct Lisp_Save_Value
1199 { 1199 {
1200 int type : 16; /* = Lisp_Misc_Save_Value */ 1200 int type : 16; /* = Lisp_Misc_Save_Value */
1201 unsigned gcmarkbit : 1; 1201 unsigned gcmarkbit : 1;
1202 int spacer : 15; 1202 int spacer : 14;
1203 /* If DOGC is set, POINTER is the address of a memory
1204 area containing INTEGER potential Lisp_Objects. */
1205 unsigned int dogc : 1;
1203 void *pointer; 1206 void *pointer;
1204 int integer; 1207 int integer;
1205 }; 1208 };
@@ -3270,22 +3273,6 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3270 } \ 3273 } \
3271 } while (0) 3274 } while (0)
3272 3275
3273/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects.
3274 Temporarily inhibits GC since that array is unknow to GC. */
3275
3276#define SAFE_ALLOCA_LISP(buf, size) \
3277 do { \
3278 if ((size) < MAX_ALLOCA) \
3279 buf = (Lisp_Object *) alloca (size); \
3280 else \
3281 { \
3282 buf = (Lisp_Object *) xmalloc (size); \
3283 inhibit_garbage_collection(); \
3284 record_unwind_protect (safe_alloca_unwind, \
3285 make_save_value (buf, 0)); \
3286 } \
3287 } while (0)
3288
3289/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ 3276/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
3290 3277
3291#define SAFE_FREE(size) \ 3278#define SAFE_FREE(size) \
@@ -3295,6 +3282,29 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3295 } while (0) 3282 } while (0)
3296 3283
3297 3284
3285/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */
3286
3287#define SAFE_ALLOCA_LISP(buf, nelt) \
3288 do { \
3289 int size_ = (nelt) * sizeof (Lisp_Object); \
3290 if (size_ < MAX_ALLOCA) \
3291 buf = (Lisp_Object *) alloca (size_); \
3292 else \
3293 { \
3294 Lisp_Object arg_; \
3295 buf = (Lisp_Object *) xmalloc (size_); \
3296 arg_ = make_save_value (buf, nelt); \
3297 XSAVE_VALUE (arg_)->dogc = 1; \
3298 record_unwind_protect (safe_alloca_unwind, arg_); \
3299 } \
3300 } while (0)
3301
3302#define SAFE_FREE_LISP(nelt) \
3303 do { \
3304 if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
3305 unbind_to (sa_count, Qnil); \
3306 } while (0)
3307
3298 3308
3299 3309
3300#endif /* EMACS_LISP_H */ 3310#endif /* EMACS_LISP_H */