summaryrefslogtreecommitdiff
path: root/src/lisp.h
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2004-10-26 22:37:02 +0000
committerKim F. Storm <storm@cua.dk>2004-10-26 22:37:02 +0000
commitc33188d937816a0c9dbbc271db54525fee73170b (patch)
tree4196d945fc69d7e9aa186d5beb214481fb0ec04b /src/lisp.h
parent8671340582b5553c8810e66455f52cfd89076bdd (diff)
downloademacs-c33188d937816a0c9dbbc271db54525fee73170b.tar.gz
(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.
Diffstat (limited to 'src/lisp.h')
-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;
extern Lisp_Object safe_alloca_unwind (Lisp_Object);
#define USE_SAFE_ALLOCA \
- int sa_count = SPECPDL_INDEX ()
+ int sa_count = SPECPDL_INDEX (), sa_must_free = 0
/* SAFE_ALLOCA allocates a simple buffer. */
@@ -3274,6 +3274,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
else \
{ \
buf = (type) xmalloc (size); \
+ sa_must_free++; \
record_unwind_protect (safe_alloca_unwind, \
make_save_value (buf, 0)); \
} \
@@ -3281,10 +3282,12 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
/* SAFE_FREE frees xmalloced memory and enables GC as needed. */
-#define SAFE_FREE(size) \
+#define SAFE_FREE() \
do { \
- if ((size) >= MAX_ALLOCA) \
+ if (sa_must_free) { \
+ sa_must_free = 0; \
unbind_to (sa_count, Qnil); \
+ } \
} while (0)
@@ -3301,17 +3304,11 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
buf = (Lisp_Object *) xmalloc (size_); \
arg_ = make_save_value (buf, nelt); \
XSAVE_VALUE (arg_)->dogc = 1; \
+ sa_must_free++; \
record_unwind_protect (safe_alloca_unwind, arg_); \
} \
} while (0)
-#define SAFE_FREE_LISP(nelt) \
- do { \
- if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \
- unbind_to (sa_count, Qnil); \
- } while (0)
-
-
#endif /* EMACS_LISP_H */