* lib/getcwd.c (__getcwd): Remove redundant comparison of buf to NULL.
[gnulib.git] / lib / alloca.c
index c4db187..3a1f4e2 100644 (file)
@@ -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 <config.h>
-#endif
+#include <config.h>
+
+#include <alloca.h>
 
 #include <string.h>
 #include <stdlib.h>
 #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.  */
@@ -196,25 +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);
 
-    if (new == 0)
-      abort();
+    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);
   }
 }