29 static char SCCSid[] =
"@(#)alloca.c 1.1";
32 #include "ruby/config.h"
41 #ifndef STACK_DIRECTION
44 -- must know STACK_DIRECTION at compile-time
50 typedef void *pointer;
52 typedef char *pointer;
57 #ifdef RUBY_LIB_PREFIX
58 #define xmalloc ruby_xmalloc
59 #define xfree ruby_xfree
75 #ifndef STACK_DIRECTION
76 #define STACK_DIRECTION 0
79 #if STACK_DIRECTION != 0
81 #define STACK_DIR STACK_DIRECTION
86 #define STACK_DIR stack_dir
89 find_stack_direction ()
91 static char *addr =
NULL;
99 find_stack_direction ();
120 #define ALIGN_SIZE sizeof(double)
125 char align[ALIGN_SIZE];
142 static header *last_alloca_header =
NULL;
149 register char *depth = &probe;
151 #if STACK_DIRECTION == 0
153 find_stack_direction ();
161 for (hp = last_alloca_header; hp !=
NULL;)
162 if (STACK_DIR > 0 && hp->h.deep > depth
163 || STACK_DIR < 0 && hp->h.deep < depth)
165 register header *np = hp->h.next;
167 xfree ((pointer) hp);
174 last_alloca_header = hp;
183 register pointer
new =
xmalloc (
sizeof (header) + size);
186 ((header *)
new)->h.next = last_alloca_header;
187 ((header *)
new)->h.deep = depth;
189 last_alloca_header = (header *)
new;
193 return (pointer)((
char *)
new +
sizeof(header));