Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!hp-pcd!hpfcso!hpfcdc!rer From: rer@hpfcdc.HP.COM (Rob Robason) Newsgroups: comp.sys.hp Subject: Re: alloca() on the HP9000/300 Message-ID: <5570467@hpfcdc.HP.COM> Date: 9 Aug 90 20:39:31 GMT References: <1455@tub.UUCP> Organization: HP Fort Collins, Co. Lines: 37 Oliver> Is it possible to write a "real" alloca() for the HP at all I've seen at least one hack that claimed to be an alloca() for the 300. The problem is that the author declined to guarantee that it would work from one release to the next. So it was of little use. I think this is an inherent problem with alloca()s because they rely on knowledge about how the stack is layed out in a specific implementation, if that changes due to a compiler improvement, for example, it's busted. While I know there are some pretty significant applications that make heavy use of alloca(), it has proved so troublesome that none of the standards organizations have dared touch it. Neither POSIX, SVID, XPG3, OSF nor ANSI-C support alloca(). ANSI-C, in fact makes this point in the rationale: "Some implementations provide a function (often called alloca) which allocates the requested object from automatic storage; the object is automatically freed when the calling function exits. Such a function is not efficiently implementable in a variety of environments, so it was not adopted in the standard." For this reason, most standards (and HP) are recommending that functions and applications be modified to use malloc/free or some other standard mechanism in order to be portable to the widest range of standards conforming systems. Many of the applications I've looked at that used alloca did so out of laziness, rather than need: It was a convenient way to be sure that everything was freed without having to think. In these cases the fix is easy. There are some applications where it will be hard, but possible, to work around alloca being absent. I know this isn't what you wanted to hear. You may obtain an alloca from another source and find it adequate for now. You just need to know that it's not necessarily the best way to solve the problem. Rob "Don't kill the messenger" Robason