From 899833c050abaceb2bda81e858c6ea013c4cfd74 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 24 Nov 2003 21:38:43 +0000 Subject: [PATCH] Remove dependency of alloca on xalloc. --- ChangeLog | 4 ++++ lib/ChangeLog | 10 ++++++++++ lib/alloca.c | 20 +++++++++++--------- modules/alloca | 1 - 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 890f977dc0..d3fc3612ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-11-24 Paul Eggert + + * modules/alloca: Remove dependency on xalloc. + 2003-11-17 Paul Eggert * README: Mention that S+T cannot overflow if S is the size of diff --git a/lib/ChangeLog b/lib/ChangeLog index f753cfe258..7a84430fba 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,13 @@ +2003-11-24 Paul Eggert + + * lib/alloca.c: Remove dependency on xalloc module. + (xalloc_die): Remove. + (memory_full) [!defined emacs]: New macro. + [!defined emacs]: Don't include xalloc.h. + (alloca): Invoke memory_full, not xalloc_die, if malloc fails or + address arithmetic overflows. Change datatypes a bit to avoid + unnecessary casts. + 2003-11-22 Jim Meyering * xmalloc.c (x2nrealloc_inline): Fix typos in comments: s/size/size_t/. diff --git a/lib/alloca.c b/lib/alloca.c index 5e2521b363..a580078696 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -31,13 +31,12 @@ #ifdef emacs # include "lisp.h" # include "blockinput.h" -# define xalloc_die() memory_full () # ifdef EMACS_FREE # undef free # define free EMACS_FREE # endif #else -# include +# define memory_full() abort () #endif /* If compiling with GCC 2, this file's not needed. */ @@ -196,22 +195,25 @@ alloca (size_t size) { /* Address of header. */ - register void *new; + register header *new; size_t combined_size = sizeof (header) + size; if (combined_size < sizeof (header)) - xalloc_die (); + memory_full (); - new = xmalloc (combined_size); + new = malloc (combined_size); - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; + if (! new) + memory_full (); - last_alloca_header = (header *) new; + new->h.next = last_alloca_header; + new->h.deep = depth; + + last_alloca_header = new; /* User storage begins just after header. */ - return (void *) ((char *) new + sizeof (header)); + return (void *) (new + 1); } } diff --git a/modules/alloca b/modules/alloca index 5719b4b593..f93d5e3861 100644 --- a/modules/alloca +++ b/modules/alloca @@ -7,7 +7,6 @@ lib/alloca.c m4/alloca.m4 Depends-on: -xalloc configure.ac: gl_FUNC_ALLOCA -- 2.30.2