Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
alloca
◄Summary► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The alloca routine allocates <size> bytes from the program's
stack. The allocated space is automatically freed when the calling
function is exited.
Use of the alloca function is not recommended. The function is
supported only for source compatibility with earlier releases.
Routines using alloca should be compiled with optimization
turned off (i.e., with the /Od option).
When you compile with optimization on (either by default or by
using one of the /O options), the stack pointer may not be
restored properly in functions that have no local variables and
also reference the alloca function. To ensure that the stack
pointer is properly restored, make sure that any function
referencing alloca declares at least one local variable.
The pointer value returned by alloca should never be passed as an
argument to the free function, nor should alloca be used in an
expression that is an argument to a function.
Return Value
The alloca routine returns a void pointer to the allocated space,
which is guaranteed to be suitably aligned for storage of any type
of object. To get a pointer to a type other than void, use a type
cast on the return value. The return value is NULL if the space
cannot be allocated.
-♦-