Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header alloca.h in Windows

I can't see any alloca.h equivalent in Visual C 2010. How can one perform stack allocation in Visual C on Windows? I miss the function alloca.

like image 940
Cartesius00 Avatar asked Jul 15 '11 09:07

Cartesius00


People also ask

What is Alloca H?

The alloca() function is machine- and compiler-dependent. For certain applications, its use can improve efficiency compared to the use of malloc(3) plus free(3). In certain cases, it can also simplify memory deallocation in applications that use longjmp(3) or siglongjmp(3). Otherwise, its use is discouraged.

How does alloca work?

alloca() allocates memory on the stack rather than on the heap, as in the case of malloc() . So, when I return from the routine the memory is freed. So, actually this solves my problem of freeing up dynamically allocated memory.


1 Answers

See _alloca. Visual C uses an _ prefix for non-standard functions in the C headers.

like image 141
MSalters Avatar answered Oct 03 '22 21:10

MSalters