alloca (was vs var-len auto arrays)

John Campbell jdc at naucse.UUCP
Fri Apr 28 01:02:20 AEST 1989


>From article <11344 at tekecs.GWD.TEK.COM>, by andrew at frip.wv.tek.com (Andrew Klossner):
>> Are there architectures that will not allow you to implement this?
  (alloca)
 
> No, with compiler assist you can always implement it; but its
> complexity can approach that of marking all mallocs and teaching the
> compiler (and longjmp) to call un_malloc_temporaries on each procedure
> return.

Ah, but that's the rub.  What if you already have your compiler.  In
other words, what if you know of some nice useful software that *someone*
sprinkled alloca's in AND you have some silly vendor supplied C compiler.
In one case (at least) you'll have to write a stack manipulator (not in
'C') and even compile without optimizing.  Often, it turns out, you'll
find (with the vendor's compiler) that you're better off rewriting the
offending section in order to turn optimize back on. 

I don't remember alloca() making it to the ANSI standard library.  I hereby
request that only those who write *useless* code use alloca()! :-)
-- 
	John Campbell               ...!arizona!naucse!jdc
                                    CAMPBELL at NAUVAX.bitnet
	unix?  Sure send me a dozen, all different colors.



More information about the Comp.unix.wizards mailing list