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.

Syntax

void *alloca(size_t size);

Usage

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.

Note:

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

Returns in size a pointer to the number of bytes of memory allocated.

Non-ConfidentialPDF file icon PDF versionARM DUI0475M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.