29 static char SCCSid[] =
"@(#)alloca.c 1.1";
32 #include "ruby/config.h" 43 #ifndef STACK_DIRECTION 52 typedef void *pointer;
54 typedef char *pointer;
61 #define xmalloc ruby_xmalloc 62 #define xfree ruby_xfree 77 #ifndef STACK_DIRECTION 78 #define STACK_DIRECTION 0 81 #if STACK_DIRECTION != 0 83 #define STACK_DIR STACK_DIRECTION 88 #define STACK_DIR stack_dir 91 find_stack_direction ()
93 static char *addr =
NULL;
101 find_stack_direction ();
122 #define ALIGN_SIZE sizeof(double) 127 char align[ALIGN_SIZE];
144 static header *last_alloca_header =
NULL;
151 register char *depth = &probe;
153 #if STACK_DIRECTION == 0 155 find_stack_direction ();
163 for (hp = last_alloca_header; hp !=
NULL;)
164 if (STACK_DIR > 0 && hp->h.deep > depth
165 || STACK_DIR < 0 && hp->h.deep < depth)
167 register header *np = hp->h.next;
169 xfree ((pointer) hp);
176 last_alloca_header = hp;
185 register pointer
new =
xmalloc (
sizeof (header) + size);
188 ((header *)
new)->h.next = last_alloca_header;
189 ((header *)
new)->h.deep = depth;
191 last_alloca_header = (header *)
new;
195 return (pointer)((
char *)
new +
sizeof(header));
RUBY_SYMBOL_EXPORT_BEGIN void * alloca()