alloca - temporary memory allocator
#include <alloca.h> void *alloca(size_t size);
The alloca() function allocates size bytes of space in the stack frame of the caller, and returns a pointer to the allocated block. This temporary space is automatically freed when the caller returns or calls a stack frame altering function such as setjmp(3C). If the allocated block extends beyond the current stack limit, the resulting behavior is undefined.
Upon successful completion, alloca() returns a pointer to space suitably aligned (after possible pointer coercion) for storage of any type of object.
alloca() may return a pointer to memory which causes a stack overflow if the full block is accessed.
Memory allocated by this function may be on pages with the PROT_EXEC access protections disabled to block execution of machine instructions, depending on the system settings for NXSTACK in sxadm(8) and any –z sx=nxstack options that were passed to ld(1) when linking the application. These settings may be overridden for individual pages by calling mprotect(2).
See attributes(7) for descriptions of the following attributes:
The implementation of alloca() is both machine and compiler dependent; its use is discouraged.
Undefined results will occur if the size requested from a process's main thread for a block of memory exceeds the maximum size of a process's stack, which can be obtained with getrlimit(2); or if the size requested from another thread exceeds the maximum size of the thread stack, which can be obtained with pthread_attr_getstacksize(3C).