_alloca (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Allocates memory on the stack.

void *_alloca( size_tsize);

Parameters

  • size
    Bytes to be allocated from stack

Return Values

The _alloca routine returns a void pointer to the allocated space, which is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than char, use a type cast on the return value. A stack overflow exception is generated if the space cannot be allocated.

Remarks

_alloca allocates size bytes from the program stack. The allocated space is automatically freed when the calling function exits. Therefore, do not pass the pointer value returned by _alloca as an argument to free.

There are restrictions to explicitly calling _alloca in an exception handler (EH).

EH routines that run on x86-class processors operate in their own memory frame: They perform their tasks in memory space that is not based on the current ___location of the stack pointer of the enclosing function.

The most common implementations include Windows NT structured exception handling (SEH) and C++ catch clause expressions. Therefore, explicitly calling _alloca in any of the following scenarios results in program failure during the return to the calling EH routine:

  • Windows NT SEH exception filter expression: __except ( alloca() )
  • Windows NT SEH final exception handler: __finally { alloca() }
  • C++ EH catch clause expression

However, _alloca can be called directly from within an EH routine or from an application-supplied callback that gets invoked by one of the EH scenarios listed above.

Requirements

OS Versions: Windows CE 2.0 and later.
Header: malloc.h.
Link Library: coredll.dll.

See Also

calloc | malloc | realloc

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.