stack memory allocation

glenn at nsc.UUCP glenn at nsc.UUCP
Thu Jul 21 02:56:38 AEST 1983


If you are interested in portability, _don't_ use alloca.  Some
architectures make assumptions about how routine stack frames are
laid out that make it impossible to port this routine.

I ran across this problem when porting SCCS to our NS16000-based
system.  When I first bumped into alloca, I thought it was a neat
idea.  Then I tried to port it and discovered that, no matter how
I tried playing with the stack and frame pointers, there was no way
to maintain stack frame integrity so that subsequent function calls
would work.  I ended up replacing invocations of alloca with malloc/
free pairs.

BTW: don't blame this routine on Berkeley.  It shows up on USG systems
as part of libPW.a, almost certainly predating its appearances on
Berkeley systems.

		-- Glenn Skinner
		...!{fortune,menlo70}!nsc!glenn



More information about the Comp.unix.wizards mailing list