+2003-11-24 Paul Eggert <eggert@twinsun.com>
+
+ * modules/alloca: Remove dependency on xalloc.
+
2003-11-17 Paul Eggert <eggert@twinsun.com>
* README: Mention that S+T cannot overflow if S is the size of
+2003-11-24 Paul Eggert <eggert@twinsun.com>
+
+ * 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 <jim@meyering.net>
* xmalloc.c (x2nrealloc_inline): Fix typos in comments: s/size/size_t/.
#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 <xalloc.h>
+# define memory_full() abort ()
#endif
/* If compiling with GCC 2, this file's not needed. */
{
/* 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);
}
}