"Richard Bos" <rl*@hoekstra-uitgeverij.nl> wrote in message
news:40****************@news.individual.net...
ni*************@hotmail.com (Nitin Bhardwaj) wrote:
Is it hard to implement in a platform-independent way?
OR there is no need for it?
Both. RTFAQ: <http://www.eskimo.com/~scs/C-faq/q7.32.html>.
alloca can be tricky to implement correctly, as the FAQ points out. The
compilers I've used that did implement it all did implement it correctly,
even if there were already things on the stack like partial function
arguments. alloca is pretty handy for fast allocation of temporary buffers -
it's thread safe, exception safe, and the automatic cleanup is nice when a
function has complex logic with multiple exits.
I've had to port some code that used alloca to a system that couldn't
support it. The result usually was an uglification of the code, as a bunch
of code needed to be added to keep track of all the allocated bits so they
could be properly cleaned up.
Fortunately, I don't have to use that miserable system any more <g>, and I
regularly use alloca. It's portable to all the compilers I need to use. I
like alloca, and put it in the D programming language as well.
Sure, alloca is not in the C standard. But that standard specifies a minimum
standard, the realities of the compiler business are that alloca will be
supported if it is reasonably feasible to get it to work on the system.
-Walter
www.digitalmars.com free C/C++/D compilers