4.14.8. alloca()

The alloca() function allocates local storage in a function. It returns a pointer to size bytes of memory, or NULL if not enough memory was available. The default implementation returns an 8-byte aligned block of memory.

Memory returned from alloca() must never be passed to free(). Instead, the memory is deallocated 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 deallocated by the call to longjmp().

This function is a common nonstandard extension to many C libraries.


void* alloca(size_t size);

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D