# HG changeset patch # User Kim F. Storm # Date 1087857329 0 # Node ID a803de48faef189ea8154043b7b3b001b871a6de # Parent fb8588385aacda04d4f84e7349b6405d3c5c5f33 (SAFE_ALLOCA_LISP): New macro to allocate Lisp_Objects. Temporarily inhibits GC if memory is xmalloc'ed, as the Lisp_Objects in that memory area are unknown to GC. Add comments. diff -r fb8588385aac -r a803de48faef src/lisp.h --- a/src/lisp.h Mon Jun 21 22:35:00 2004 +0000 +++ b/src/lisp.h Mon Jun 21 22:35:29 2004 +0000 @@ -3256,6 +3256,8 @@ #define USE_SAFE_ALLOCA \ int sa_count = SPECPDL_INDEX () +/* SAFE_ALLOCA allocates a simple buffer. */ + #define SAFE_ALLOCA(buf, type, size) \ do { \ if ((size) < MAX_ALLOCA) \ @@ -3268,6 +3270,24 @@ } \ } while (0) +/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. + Temporarily inhibits GC since that array is unknow to GC. */ + +#define SAFE_ALLOCA_LISP(buf, size) \ + do { \ + if ((size) < MAX_ALLOCA) \ + buf = (Lisp_Object *) alloca (size); \ + else \ + { \ + buf = (Lisp_Object *) xmalloc (size); \ + inhibit_garbage_collection(); \ + record_unwind_protect (safe_alloca_unwind, \ + make_save_value (buf, 0)); \ + } \ + } while (0) + +/* SAFE_FREE frees xmalloced memory and enables GC as needed. */ + #define SAFE_FREE(size) \ do { \ if ((size) >= MAX_ALLOCA) \