1203 |
{ |
{ |
1204 |
int type : 16; /* = Lisp_Misc_Save_Value */ |
int type : 16; /* = Lisp_Misc_Save_Value */ |
1205 |
unsigned gcmarkbit : 1; |
unsigned gcmarkbit : 1; |
1206 |
int spacer : 15; |
int spacer : 14; |
1207 |
|
/* If DOGC is set, POINTER is the address of a memory |
1208 |
|
area containing INTEGER potential Lisp_Objects. */ |
1209 |
|
unsigned int dogc : 1; |
1210 |
void *pointer; |
void *pointer; |
1211 |
int integer; |
int integer; |
1212 |
}; |
}; |
2501 |
extern void display_malloc_warning P_ ((void)); |
extern void display_malloc_warning P_ ((void)); |
2502 |
extern int inhibit_garbage_collection P_ ((void)); |
extern int inhibit_garbage_collection P_ ((void)); |
2503 |
extern Lisp_Object make_save_value P_ ((void *, int)); |
extern Lisp_Object make_save_value P_ ((void *, int)); |
2504 |
|
extern void free_misc P_ ((Lisp_Object)); |
2505 |
extern void free_marker P_ ((Lisp_Object)); |
extern void free_marker P_ ((Lisp_Object)); |
2506 |
extern void free_cons P_ ((struct Lisp_Cons *)); |
extern void free_cons P_ ((struct Lisp_Cons *)); |
2507 |
extern void init_alloc_once P_ ((void)); |
extern void init_alloc_once P_ ((void)); |
3294 |
: Fcons ((el), (check))))) |
: Fcons ((el), (check))))) |
3295 |
|
|
3296 |
|
|
3297 |
|
/* SAFE_ALLOCA normally allocates memory on the stack, but if size is |
3298 |
|
larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ |
3299 |
|
|
3300 |
|
#define MAX_ALLOCA 16*1024 |
3301 |
|
|
3302 |
|
extern Lisp_Object safe_alloca_unwind (Lisp_Object); |
3303 |
|
|
3304 |
|
#define USE_SAFE_ALLOCA \ |
3305 |
|
int sa_count = SPECPDL_INDEX () |
3306 |
|
|
3307 |
|
/* SAFE_ALLOCA allocates a simple buffer. */ |
3308 |
|
|
3309 |
|
#define SAFE_ALLOCA(buf, type, size) \ |
3310 |
|
do { \ |
3311 |
|
if ((size) < MAX_ALLOCA) \ |
3312 |
|
buf = (type) alloca (size); \ |
3313 |
|
else \ |
3314 |
|
{ \ |
3315 |
|
buf = (type) xmalloc (size); \ |
3316 |
|
record_unwind_protect (safe_alloca_unwind, \ |
3317 |
|
make_save_value (buf, 0)); \ |
3318 |
|
} \ |
3319 |
|
} while (0) |
3320 |
|
|
3321 |
|
/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
3322 |
|
|
3323 |
|
#define SAFE_FREE(size) \ |
3324 |
|
do { \ |
3325 |
|
if ((size) >= MAX_ALLOCA) \ |
3326 |
|
unbind_to (sa_count, Qnil); \ |
3327 |
|
} while (0) |
3328 |
|
|
3329 |
|
|
3330 |
|
/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ |
3331 |
|
|
3332 |
|
#define SAFE_ALLOCA_LISP(buf, nelt) \ |
3333 |
|
do { \ |
3334 |
|
int size_ = (nelt) * sizeof (Lisp_Object); \ |
3335 |
|
if (size_ < MAX_ALLOCA) \ |
3336 |
|
buf = (Lisp_Object *) alloca (size_); \ |
3337 |
|
else \ |
3338 |
|
{ \ |
3339 |
|
Lisp_Object arg_; \ |
3340 |
|
buf = (Lisp_Object *) xmalloc (size_); \ |
3341 |
|
arg_ = make_save_value (buf, nelt); \ |
3342 |
|
XSAVE_VALUE (arg_)->dogc = 1; \ |
3343 |
|
record_unwind_protect (safe_alloca_unwind, arg_); \ |
3344 |
|
} \ |
3345 |
|
} while (0) |
3346 |
|
|
3347 |
|
#define SAFE_FREE_LISP(nelt) \ |
3348 |
|
do { \ |
3349 |
|
if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \ |
3350 |
|
unbind_to (sa_count, Qnil); \ |
3351 |
|
} while (0) |
3352 |
|
|
3353 |
|
|
3354 |
|
|
3355 |
#endif /* EMACS_LISP_H */ |
#endif /* EMACS_LISP_H */ |
3356 |
|
|
3357 |
/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e |
/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e |