Manpage of ALLOCA
ALLOCASection: Linux Programmer's Manual (3)
NAMEalloca - allocate memory that is automatically freed
DESCRIPTIONThe alloca() function allocates sizebytes 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 VALUEThe alloca() function returns a pointer to the beginning of the allocated space. If the allocation causes stack overflow, program behavior is undefined.
ATTRIBUTESFor an explanation of the terms used in this section, see attributes(7).
CONFORMING TOThis function is not in POSIX.1.
NOTESThe alloca() function is machine- and compiler-dependent. For certain applications, its use can improve efficiency compared to the use of malloc(3) plus free(3). In certain cases, it can also simplify memory deallocation in applications that use longjmp(3) or siglongjmp(3). Otherwise, its use is discouraged.
Do not attempt to free(3) space allocated by alloca()!
Notes on the GNU versionNormally, gcc(1) translates calls to alloca() with inlined code. This is not done when either the -ansi, -std=c89, -std=c99, or the -std=c11option is given andthe header <alloca.h>is not included. Otherwise, (without an -ansi or -std=c* option) the glibc version of <stdlib.h>includes <alloca.h>and that contains the lines:
#ifdef __GNUC__ #define alloca(size) __builtin_alloca (size) #endifwith messy consequences if one has a private version of this function.
The fact that the code is inlined means that it is impossible to take the address of this function, or to change its behavior by linking with a different library.
BUGSThere is no error indication if the stack frame cannot be extended. (However, after a failed allocation, the program is likely to receive a SIGSEGVsignal if it attempts to access the unallocated space.)
On many systems 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.
SEE ALSObrk(2), longjmp(3), malloc(3)
This document was created by man2html, using the manual pages.
Time: 22:27:57 GMT, June 20, 2016 Click Here!