alloca

Allocates a block of memory on the stack.

Library:LibC
Classification:Other
Service:Memory Management

Syntax

  #include <alloca.h> 
   
  void *alloca (
        size_t   size);
  

Parameters

size

(IN) Specifies the size (in bytes) of the block of memory.

Return Values

If successful, returns a pointer to the start of the allocated memory.

If insufficient memory is available, returns NULL.

WARNING:This function is compiler-specific. Some compilers do no error checking and allow you to allocate memory that is not available on your stack. Check the documentation for your compiler before using this function.

Remarks

Memory allocation is not limited to 64 KB. The size parameter is 32 bits.

The alloca function allocates memory space for an object of size bytes from the stack. The allocated space is automatically discarded when the current function exits.

The alloca function should not be used in an expression that is an argument to a function, because the alloca function manipulates the stack.

See Also