Is there a stackalloc function for C?

c, memory-management, stack

Solution

There's `alloca` but it's non-standard. Moreover, since C99 there's a feature called "Variable Length Arrays".

int n;
scanf("%d", &n);
int v[n]; /* Will fail badly if n is large. */

Used sparingly and with small values VLAs can be quite nice.

Problem

Is there a stackalloc function implemented in C that allows you to allocate a variable length array on the stack, like stackalloc in C#?

Original source