3293 |
extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
3294 |
|
|
3295 |
#define USE_SAFE_ALLOCA \ |
#define USE_SAFE_ALLOCA \ |
3296 |
int sa_count = SPECPDL_INDEX () |
int sa_count = SPECPDL_INDEX (), sa_must_free = 0 |
3297 |
|
|
3298 |
/* SAFE_ALLOCA allocates a simple buffer. */ |
/* SAFE_ALLOCA allocates a simple buffer. */ |
3299 |
|
|
3304 |
else \ |
else \ |
3305 |
{ \ |
{ \ |
3306 |
buf = (type) xmalloc (size); \ |
buf = (type) xmalloc (size); \ |
3307 |
|
sa_must_free++; \ |
3308 |
record_unwind_protect (safe_alloca_unwind, \ |
record_unwind_protect (safe_alloca_unwind, \ |
3309 |
make_save_value (buf, 0)); \ |
make_save_value (buf, 0)); \ |
3310 |
} \ |
} \ |
3312 |
|
|
3313 |
/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
3314 |
|
|
3315 |
#define SAFE_FREE(size) \ |
#define SAFE_FREE() \ |
3316 |
do { \ |
do { \ |
3317 |
if ((size) >= MAX_ALLOCA) \ |
if (sa_must_free) { \ |
3318 |
|
sa_must_free = 0; \ |
3319 |
unbind_to (sa_count, Qnil); \ |
unbind_to (sa_count, Qnil); \ |
3320 |
|
} \ |
3321 |
} while (0) |
} while (0) |
3322 |
|
|
3323 |
|
|
3334 |
buf = (Lisp_Object *) xmalloc (size_); \ |
buf = (Lisp_Object *) xmalloc (size_); \ |
3335 |
arg_ = make_save_value (buf, nelt); \ |
arg_ = make_save_value (buf, nelt); \ |
3336 |
XSAVE_VALUE (arg_)->dogc = 1; \ |
XSAVE_VALUE (arg_)->dogc = 1; \ |
3337 |
|
sa_must_free++; \ |
3338 |
record_unwind_protect (safe_alloca_unwind, arg_); \ |
record_unwind_protect (safe_alloca_unwind, arg_); \ |
3339 |
} \ |
} \ |
3340 |
} while (0) |
} while (0) |
3341 |
|
|
|
#define SAFE_FREE_LISP(nelt) \ |
|
|
do { \ |
|
|
if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \ |
|
|
unbind_to (sa_count, Qnil); \ |
|
|
} while (0) |
|
|
|
|
|
|
|
3342 |
|
|
3343 |
#endif /* EMACS_LISP_H */ |
#endif /* EMACS_LISP_H */ |
3344 |
|
|