Yeah their take on goto is a bit odd given that it's probably the sanest way to do "cascading" error handling in C given that we don't have RAII or exceptions.
You just replace this:
void f(int n)
{
float *x = malloc(n * sizeof*x);
// ...
free(x);
}
with this: void f(int n)
{
float x[n];
// ...
}
edit: and you can exit your function anywhere without leaking.I just need to call your example function with the right n to corrupt the stack.
In the case of an operating system (the subject of TFA) pre-allocating everything is obviously completely impractical and alloca won't help since you can't return the memory outside of the stack frame. I'd wager that there are very few uses of goto in kernel code that could successfully be replaced by alloca (the fact that kernel stacks tend to be very shallow wouldn't help either).
With pre allocation you usually also end up creating your own resource management within the pre allocated pool and then you are back to the resource management problem...