]> code.delx.au - gnu-emacs/blobdiff - src/alloca.c
Set maintainer to FSF, since author cannot
[gnu-emacs] / src / alloca.c
index cab9645b7e183ae2f31330ae6df0bbbc7a2ed18a..087e990ab1e73aefe39b538480809ec7a5128733 100644 (file)
    your main control loop, etc. to force garbage collection.  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef emacs
+#include "lisp.h"
+#include "blockinput.h"
 #endif
 
 /* If compiling with GCC 2, this file's not needed.  */
@@ -62,7 +74,9 @@ typedef void *pointer;
 typedef char *pointer;
 #endif
 
+#ifndef NULL
 #define        NULL    0
+#endif
 
 /* Different portions of Emacs need to call different versions of
    malloc.  The Emacs executable needs alloca to call xmalloc, because
@@ -74,8 +88,11 @@ typedef char *pointer;
 
    Callers below should use malloc.  */
 
-#ifndef emacs
+#ifdef emacs
 #define malloc xmalloc
+#ifdef EMACS_FREE
+#define free EMACS_FREE
+#endif
 #endif
 extern pointer malloc ();
 
@@ -167,11 +184,15 @@ alloca (size)
 #endif
 
   /* Reclaim garbage, defined as all alloca'd storage that
-     was allocated from deeper in the stack than currently. */
+     was allocated from deeper in the stack than currently.  */
 
   {
     register header *hp;       /* Traverses linked list.  */
 
+#ifdef emacs
+    BLOCK_INPUT;
+#endif
+
     for (hp = last_alloca_header; hp != NULL;)
       if ((STACK_DIR > 0 && hp->h.deep > depth)
          || (STACK_DIR < 0 && hp->h.deep < depth))
@@ -186,6 +207,10 @@ alloca (size)
        break;                  /* Rest are not deeper.  */
 
     last_alloca_header = hp;   /* -> last valid storage.  */
+
+#ifdef emacs
+    UNBLOCK_INPUT;
+#endif
   }
 
   if (size == 0)
@@ -197,6 +222,9 @@ alloca (size)
     register pointer new = malloc (sizeof (header) + size);
     /* Address of header.  */
 
+    if (new == 0)
+      abort();
+
     ((header *) new)->h.next = last_alloca_header;
     ((header *) new)->h.deep = depth;
 
@@ -326,7 +354,7 @@ struct stk_trailer
 
 #ifdef CRAY2
 /* Determine a "stack measure" for an arbitrary ADDRESS.
-   I doubt that "lint" will like this much. */
+   I doubt that "lint" will like this much.  */
 
 static long
 i00afunc (long *address)