diff options
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lisp.h b/src/lisp.h index 5e4d87595eb..0ab02941c9b 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3307,7 +3307,7 @@ extern Lisp_Object Vdirectory_sep_char; | |||
| 3307 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); | 3307 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
| 3308 | 3308 | ||
| 3309 | #define USE_SAFE_ALLOCA \ | 3309 | #define USE_SAFE_ALLOCA \ |
| 3310 | int sa_count = SPECPDL_INDEX () | 3310 | int sa_count = SPECPDL_INDEX (), sa_must_free = 0 |
| 3311 | 3311 | ||
| 3312 | /* SAFE_ALLOCA allocates a simple buffer. */ | 3312 | /* SAFE_ALLOCA allocates a simple buffer. */ |
| 3313 | 3313 | ||
| @@ -3318,6 +3318,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3318 | else \ | 3318 | else \ |
| 3319 | { \ | 3319 | { \ |
| 3320 | buf = (type) xmalloc (size); \ | 3320 | buf = (type) xmalloc (size); \ |
| 3321 | sa_must_free++; \ | ||
| 3321 | record_unwind_protect (safe_alloca_unwind, \ | 3322 | record_unwind_protect (safe_alloca_unwind, \ |
| 3322 | make_save_value (buf, 0)); \ | 3323 | make_save_value (buf, 0)); \ |
| 3323 | } \ | 3324 | } \ |
| @@ -3325,10 +3326,12 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3325 | 3326 | ||
| 3326 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ | 3327 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
| 3327 | 3328 | ||
| 3328 | #define SAFE_FREE(size) \ | 3329 | #define SAFE_FREE() \ |
| 3329 | do { \ | 3330 | do { \ |
| 3330 | if ((size) >= MAX_ALLOCA) \ | 3331 | if (sa_must_free) { \ |
| 3332 | sa_must_free = 0; \ | ||
| 3331 | unbind_to (sa_count, Qnil); \ | 3333 | unbind_to (sa_count, Qnil); \ |
| 3334 | } \ | ||
| 3332 | } while (0) | 3335 | } while (0) |
| 3333 | 3336 | ||
| 3334 | 3337 | ||
| @@ -3345,17 +3348,11 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3345 | buf = (Lisp_Object *) xmalloc (size_); \ | 3348 | buf = (Lisp_Object *) xmalloc (size_); \ |
| 3346 | arg_ = make_save_value (buf, nelt); \ | 3349 | arg_ = make_save_value (buf, nelt); \ |
| 3347 | XSAVE_VALUE (arg_)->dogc = 1; \ | 3350 | XSAVE_VALUE (arg_)->dogc = 1; \ |
| 3351 | sa_must_free++; \ | ||
| 3348 | record_unwind_protect (safe_alloca_unwind, arg_); \ | 3352 | record_unwind_protect (safe_alloca_unwind, arg_); \ |
| 3349 | } \ | 3353 | } \ |
| 3350 | } while (0) | 3354 | } while (0) |
| 3351 | 3355 | ||
| 3352 | #define SAFE_FREE_LISP(nelt) \ | ||
| 3353 | do { \ | ||
| 3354 | if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \ | ||
| 3355 | unbind_to (sa_count, Qnil); \ | ||
| 3356 | } while (0) | ||
| 3357 | |||
| 3358 | |||
| 3359 | 3356 | ||
| 3360 | #endif /* EMACS_LISP_H */ | 3357 | #endif /* EMACS_LISP_H */ |
| 3361 | 3358 | ||