4.2 alloca()

Defined in alloca.h, the alloca() function allocates local storage in a function. It returns a pointer to the number of bytes of memory allocated.


void *alloca(size_t size);


The default implementation returns an eight-byte aligned block of memory on the stack.
Memory returned from alloca() must never be passed to free(). Instead, the memory is de-allocated automatically when the function that called alloca() returns.


alloca() must not be called through a function pointer. You must take care when using alloca() and setjmp() in the same function, because memory allocated by alloca() between calling setjmp() and longjmp() is de-allocated by the call to longjmp().
This function is a common nonstandard extension to many C libraries.


Returns in size a pointer to the number of bytes of memory allocated.
Related concepts
1.5.3 ARM C libraries and thread-safe functions
Related reference
1.7.1 Building an application without the C library
4.59 Thread-safe C library functions
Non-ConfidentialPDF file icon PDF versionARM DUI0378G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.