diff options
| author | Paul Eggert | 2011-08-04 19:15:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-04 19:15:35 -0700 |
| commit | 0065d05491ce5981ea20896bb26d21dcd31e6769 (patch) | |
| tree | 13240167319d4a99ab5eacae4a883258eb2d28de /src/lisp.h | |
| parent | 18ab493650d648ab8dca651ea2698861f926e895 (diff) | |
| download | emacs-0065d05491ce5981ea20896bb26d21dcd31e6769.tar.gz emacs-0065d05491ce5981ea20896bb26d21dcd31e6769.zip | |
Adjust in response to jan.h.d's comments.
See, for example <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9196#26>.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 267bfe1b21f..83cc680b7e2 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3574,6 +3574,9 @@ extern int immediate_quit; /* Nonzero means ^G can quit instantly */ | |||
| 3574 | extern POINTER_TYPE *xmalloc (size_t); | 3574 | extern POINTER_TYPE *xmalloc (size_t); |
| 3575 | extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); | 3575 | extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); |
| 3576 | extern void xfree (POINTER_TYPE *); | 3576 | extern void xfree (POINTER_TYPE *); |
| 3577 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); | ||
| 3578 | extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); | ||
| 3579 | extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); | ||
| 3577 | 3580 | ||
| 3578 | extern char *xstrdup (const char *); | 3581 | extern char *xstrdup (const char *); |
| 3579 | 3582 | ||
| @@ -3691,6 +3694,23 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); | |||
| 3691 | } \ | 3694 | } \ |
| 3692 | } while (0) | 3695 | } while (0) |
| 3693 | 3696 | ||
| 3697 | /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * | ||
| 3698 | NITEMS items, each of the same type as *BUF. MULTIPLIER must | ||
| 3699 | positive. The code is tuned for MULTIPLIER being a constant. */ | ||
| 3700 | |||
| 3701 | #define SAFE_NALLOCA(buf, multiplier, nitems) \ | ||
| 3702 | do { \ | ||
| 3703 | if ((nitems) <= MAX_ALLOCA / sizeof *(buf) / (multiplier)) \ | ||
| 3704 | (buf) = alloca (sizeof *(buf) * (multiplier) * (nitems)); \ | ||
| 3705 | else \ | ||
| 3706 | { \ | ||
| 3707 | (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ | ||
| 3708 | sa_must_free = 1; \ | ||
| 3709 | record_unwind_protect (safe_alloca_unwind, \ | ||
| 3710 | make_save_value (buf, 0)); \ | ||
| 3711 | } \ | ||
| 3712 | } while (0) | ||
| 3713 | |||
| 3694 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ | 3714 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ |
| 3695 | 3715 | ||
| 3696 | #define SAFE_FREE() \ | 3716 | #define SAFE_FREE() \ |