summaryrefslogtreecommitdiff
path: root/missing/alloca.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/alloca.c')
-rw-r--r--missing/alloca.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/missing/alloca.c b/missing/alloca.c
index 5746497371..d039dfc2cc 100644
--- a/missing/alloca.c
+++ b/missing/alloca.c
@@ -2,10 +2,11 @@
last edit: 86/05/30 rms
include config.h, since on VMS it renames some symbols.
+ Use xmalloc instead of malloc.
This implementation of the PWB library alloca() function,
which is used to allocate space off the run-time stack so
- that it is automatically reclaimed upon procedure exit,
+ that it is automatically reclaimed upon procedure exit,
was inspired by discussions with J. Q. Johnson of Cornell.
It should work under any C implementation that uses an
@@ -28,7 +29,11 @@
static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */
#endif
-#include "config.h"
+#include "ruby/internal/config.h"
+#define X3J11 1 /* config.h should contain void if needed */
+
+#ifdef C_ALLOCA
+
#ifdef emacs
#ifdef static
/* actually, only want this if static is defined as ""
@@ -49,10 +54,15 @@ typedef void *pointer; /* generic pointer type */
typedef char *pointer; /* generic pointer type */
#endif /* X3J11 */
+#ifndef NULL
#define NULL 0 /* null pointer constant */
+#endif
-extern void free();
-extern pointer malloc();
+#define xmalloc ruby_xmalloc
+#define xfree ruby_xfree
+
+extern void xfree();
+extern pointer xmalloc();
/*
Define STACK_DIRECTION if you know the direction of stack
@@ -156,7 +166,7 @@ alloca (size) /* returns pointer to storage */
{
register header *np = hp->h.next;
- free ((pointer) hp); /* collect garbage */
+ xfree ((pointer) hp); /* collect garbage */
hp = np; /* -> next header */
}
@@ -172,7 +182,7 @@ alloca (size) /* returns pointer to storage */
/* Allocate combined header + user data storage. */
{
- register pointer new = malloc (sizeof (header) + size);
+ register pointer new = xmalloc (sizeof (header) + size);
/* address of header */
((header *)new)->h.next = last_alloca_header;
@@ -186,3 +196,4 @@ alloca (size) /* returns pointer to storage */
}
}
+#endif