* Makefile.am (DEFS): Added. automake adds -I options to DEFS,
[bpt/guile.git] / libguile / alloca.c
index 25b0ab4..b93fbe5 100644 (file)
@@ -21,6 +21,9 @@
    allocating any.  It is a good idea to use alloca(0) in
    your main control loop, etc. to force garbage collection.  */
 
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+   gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
 #ifdef HAVE_CONFIG_H
 #include <scmconfig.h>
 #endif
@@ -33,7 +36,7 @@
 #endif
 
 #ifdef emacs
-#include "blockinput.h"
+#include "libguile/blockinput.h"
 #endif
 
 /* If compiling with GCC 2, this file's not needed.  */
@@ -77,21 +80,6 @@ typedef char *pointer;
 #define        NULL    0
 #endif
 
-/* Different portions of Emacs need to call different versions of
-   malloc.  The Emacs executable needs alloca to call xmalloc, because
-   ordinary malloc isn't protected from input signals.  On the other
-   hand, the utilities in lib-src need alloca to call malloc; some of
-   them are very simple, and don't have an xmalloc routine.
-
-   Non-Emacs programs expect this to call use xmalloc.
-
-   Callers below should use malloc.  */
-
-#ifndef emacs
-#define malloc xmalloc
-#endif
-extern pointer malloc ();
-
 /* Define STACK_DIRECTION if you know the direction of stack
    growth for your system; otherwise it will be automatically
    deduced at run-time.
@@ -168,8 +156,7 @@ static header *last_alloca_header = NULL;   /* -> last alloca header.  */
    implementations of C, for example under Gould's UTX/32.  */
 
 pointer
-alloca (size)
-     unsigned size;
+alloca (unsigned size)
 {
   auto char probe;             /* Probes stack depth: */
   register char *depth = ADDRESS_FUNCTION (probe);
@@ -215,11 +202,14 @@ alloca (size)
   /* Allocate combined header + user data storage.  */
 
   {
-    register pointer new = malloc (sizeof (header) + size);
+    register pointer new = (pointer) malloc (sizeof (header) + size);
     /* Address of header.  */
 
     if (new == 0)
-      abort();
+      {
+       write (2, "alloca emulation: out of memory\n", 32);
+       abort();
+      }
 
     ((header *) new)->h.next = last_alloca_header;
     ((header *) new)->h.deep = depth;
@@ -502,3 +492,9 @@ i00afunc (long address)
 
 #endif /* no alloca */
 #endif /* not GCC version 2 */
+
+/*
+  Local Variables:
+  c-file-style: "gnu"
+  End:
+*/