|
- NAME
- alloca - memory allocator
- SYNOPSIS
- #include <alloca.h>
void *alloca(size_t size);
- DESCRIPTION
- The alloca function allocates size bytes of space in the stack frame of
the caller. This temporary space is automatically freed when the
function that called alloca returns to its caller.
- RETURN VALUE
- The alloca function returns a pointer to the beginning of the allocated
space. If the allocation causes stack over flow, program behaviour
is undefined.
- CONFORMING TO
- There is evidence that the alloca function appeared in 32v, pwb, pwb.2,
3bsd, and 4bsd. There is a man page for it in BSD 4.3.
This function is not in POSIX or SUSv3.
- NOTES
- The fact that the code is inlined, means that it is impossible to take
the address of this function, or to change its behaviour by linking with
a different library.
- BUGS
- On many systems (inluding apeNEXT) alloca cannot be used inside the list
of arguments of a function call, because the stack space reserved by
alloca would appear on the stack in the middle of the space for the
function arguments.
The inlined code consists of a few instructions adjusting the stack
pointer and does not check for stack overflow. Thus, there is no NULL
error return.
- IMPLEMENTATION for apeNEXT:
- done. No stack checking yet. The parameter size MUST be in bytes AND take alignments into account. See sizeof_aligned().
|