Oh, yes, I should have also asked for an implementation that actually
DOCUMENTS that alloca() returns NULL on failure, regardless of what
the code does.
Ok, alloca() usually relies on unportable stuff and hooks into the compiler.
Um, HOLD IT! Doesn't, by definition, the storage allocated by
_alloca(), which I presume is Microsoft's implementation of alloca(),
get freed when the function calling _alloca() returns? Doesn't
that mean that your alloca() returns a pointer to already-freed
storage? That won't work very well. alloca() doesn't like wrappers.
Also, are you guaranteed to get an exception if you overflow the
stack? Ok, if you overflow it by a meg or less, probably. If you
overflow it by the address difference between the current stack
pointer and &main, (say, a few gigabytes) maybe not. You have
demonstrated a halfway reasonable way of stack checking that probably
works most of the time.