alloca (was Re: libpw.a)

Kyle Jones kjones at talos.UUCP
Tue Apr 25 01:16:17 AEST 1989


In article <1883 at thor.acc.stolaf.edu> mike at mike@stolaf.edu writes:
 > I'm the author of GNU grep, and I firmly believe that alloca is Evil.
 > Don't use it in new programs!

Why not?  So compiler vendors can stop supporting it?  Alloca is a very
useful function to have on systems that can support it.  I believe that
it is useful enough that it should be demanded on all systems capable of
supporting it.  For the others, I can cobble a replacement that uses
malloc and put wrappers around setjmp and longjmp calls to free this
memory.  I've done this before, it's not hard.  But using a the alloca
where available is a big win in terms of time taken to allocate the
memory and programming ease when cleaning up after a longjmp.

Why throw alloca away on systems that can support it?  It's a simple
idea, stupefyingly easy to implement on stack-based machines, and makes
a certain class of programming tasks easier.



More information about the Comp.unix.wizards mailing list