aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2004-10-26 22:37:02 +0000
committerKim F. Storm2004-10-26 22:37:02 +0000
commitc33188d937816a0c9dbbc271db54525fee73170b (patch)
tree4196d945fc69d7e9aa186d5beb214481fb0ec04b
parent8671340582b5553c8810e66455f52cfd89076bdd (diff)
downloademacs-c33188d937816a0c9dbbc271db54525fee73170b.tar.gz
emacs-c33188d937816a0c9dbbc271db54525fee73170b.zip
(USE_SAFE_ALLOCA): Add and init sa_must_free integer.
(SAFE_ALLOCA, SAFE_ALLOCA_LISP): Increment it when malloc is used. (SAFE_FREE): Test it to determine if we need to unwind to free. Remove size arg. All users changed. (SAFE_FREE_LISP) Remove. All users changed to use SAFE_FREE.
-rw-r--r--src/lisp.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 9e39a0d3a8c..49d6fa9219d 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3263,7 +3263,7 @@ extern Lisp_Object Vdirectory_sep_char;
3263extern Lisp_Object safe_alloca_unwind (Lisp_Object); 3263extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3264 3264
3265#define USE_SAFE_ALLOCA \ 3265#define USE_SAFE_ALLOCA \
3266 int sa_count = SPECPDL_INDEX () 3266 int sa_count = SPECPDL_INDEX (), sa_must_free = 0
3267 3267
3268/* SAFE_ALLOCA allocates a simple buffer. */ 3268/* SAFE_ALLOCA allocates a simple buffer. */
3269 3269
@@ -3274,6 +3274,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3274 else \ 3274 else \
3275 { \ 3275 { \
3276 buf = (type) xmalloc (size); \ 3276 buf = (type) xmalloc (size); \
3277 sa_must_free++; \
3277 record_unwind_protect (safe_alloca_unwind, \ 3278 record_unwind_protect (safe_alloca_unwind, \
3278 make_save_value (buf, 0)); \ 3279 make_save_value (buf, 0)); \
3279 } \ 3280 } \
@@ -3281,10 +3282,12 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3281 3282
3282/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ 3283/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
3283 3284
3284#define SAFE_FREE(size) \ 3285#define SAFE_FREE() \
3285 do { \ 3286 do { \
3286 if ((size) >= MAX_ALLOCA) \ 3287 if (sa_must_free) { \
3288 sa_must_free = 0; \
3287 unbind_to (sa_count, Qnil); \ 3289 unbind_to (sa_count, Qnil); \
3290 } \
3288 } while (0) 3291 } while (0)
3289 3292
3290 3293
@@ -3301,17 +3304,11 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3301 buf = (Lisp_Object *) xmalloc (size_); \ 3304 buf = (Lisp_Object *) xmalloc (size_); \
3302 arg_ = make_save_value (buf, nelt); \ 3305 arg_ = make_save_value (buf, nelt); \
3303 XSAVE_VALUE (arg_)->dogc = 1; \ 3306 XSAVE_VALUE (arg_)->dogc = 1; \
3307 sa_must_free++; \
3304 record_unwind_protect (safe_alloca_unwind, arg_); \ 3308 record_unwind_protect (safe_alloca_unwind, arg_); \
3305 } \ 3309 } \
3306 } while (0) 3310 } while (0)
3307 3311
3308#define SAFE_FREE_LISP(nelt) \
3309 do { \
3310 if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
3311 unbind_to (sa_count, Qnil); \
3312 } while (0)
3313
3314
3315 3312
3316#endif /* EMACS_LISP_H */ 3313#endif /* EMACS_LISP_H */
3317 3314