X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Falloca.c;h=3a1f4e273a56b8f4f65e39c35577a1826343de24;hb=4a6f6ccf4f28947ff868115b73434a9c5af32727;hp=5e2521b363fdbdd04686b37066a29d35033e0f26;hpb=d5ebcf30ebc37012d2c110e009259ae46b88f6f5;p=gnulib.git diff --git a/lib/alloca.c b/lib/alloca.c index 5e2521b36..3a1f4e273 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -21,9 +21,9 @@ allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include + +#include #include #include @@ -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 = malloc (combined_size); - new = xmalloc (combined_size); + if (! new) + memory_full (); - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; + new->h.next = last_alloca_header; + new->h.deep = depth; - last_alloca_header = (header *) new; + last_alloca_header = new; /* User storage begins just after header. */ - return (void *) ((char *) new + sizeof (header)); + return (void *) (new + 1); } }