Keil Logo

alloca()

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 DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.