alloca() — Allocate storage from the stack
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
both | OS/390 V2R6 |
Format
#include <stdlib.h>
void *alloca(unsigned int size);
General description
The built-in alloca() function obtains memory from the stack. This eliminates the need for an explicit free() as the memory is freed when the stack is collapsed.
If the alloca() function is unable to obtain the requested storage, control will not return to the caller. Instead the application will terminate due to an out of memory condition (if the reserve stack is available and the caller is not XPLINK), or it will terminate with an abend indicating that storage could not be obtained.
To avoid infringing on the user's name space, this nonstandard function is exposed only when you use the compiler option, LANGLVL(EXTENDED). When you use LANGLVL(EXTENDED) any relevant information in the header is also exposed.
Returned value
If successful, alloca() returns the address of the requested storage.
Related information
- stdlib.h
- Built-in functions
- getcontext() — Get user context
- longjmp() — Restore stack environment
- _longjmp() — Nonlocal goto
- setcontext() — Restore user context
- setjmp() — Preserve stack environment
- _setjmp() — Set jump point for a nonlocal goto
- siglongjmp() — Restore the stack environment and signal mask
- sigsetjmp() — Save stack environment and signal mask
- swapcontext() — Save and restore user context