Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!ira.uka.de!fauern!tub!net From: net@tub.UUCP (Oliver Laumann) Newsgroups: comp.sys.hp Subject: Re: alloca() on the HP9000/300 Message-ID: <1464@tub.UUCP> Date: 16 Aug 90 17:59:43 GMT References: <1455@tub.UUCP> <1340135@hpclscu.HP.COM> <1990Aug15.101314.9626@hellgate.utah.edu> Reply-To: net@tub.UUCP (Oliver Laumann) Organization: Technical University of Berlin, Germany Lines: 34 In article <1990Aug15.101314.9626@hellgate.utah.edu> moore%cdr.utah.edu@cs.utah.edu (Tim Moore) writes: > There are all sorts of reasons why alloca is nice; the luxury of not > having to call free () is only one of them. Another feature is > automatic deallocation of storage on catching a signal or a longjmp. Yes, there are more uses for alloca() than you may dream of in your worst alloca-nightmares. One of the reasons why the application that I have ported to the HP9000 needs alloca() is that it must adjust the stack pointer on entry to main(). The program starts like this: main (ac, av) char **av; { char foo; if (Was_Dumped) { (void)alloca (INITIAL_STK_OFFSET - (original_stkbase - &foo)); } else { original_stkbase = &foo; (void)alloca (INITIAL_STK_OFFSET); } Main (ac, av); /*NOTREACHED*/ } Yes, I know, this is probably not portable to all existing machine architectures. But the feature for which this functionality is required (creation of an executable from the running program) is inherently non-portable itself. (Of course, this version of main() can be un-#ifdef-ed on systems where "dumping" cannot be supported; a conventional main() is included.) Regards, -- Oliver Laumann, Technical University of Berlin, Germany. pyramid!tub!net net@TUB.BITNET net@tub.cs.tu-berlin.de