stack memory allocation

eric%cit-vax at sri-unix.UUCP eric%cit-vax at sri-unix.UUCP
Fri Jul 1 10:47:56 AEST 1983


[4.1bsd VAX 11/780]

I want to allocate dynamic arrays in such a way that they go away
automatically when the procedure exits. Normally, I'd just use malloc
and free the memory at the end of the procedure. However, this procedure
can be interrupted (by ^C) causing a non-local goto (via setjmp/longjmp).

The easiest way to do this is to write a routine "salloc" which allocates
the space on the stack by decrementing SP and returning its new value.
(Languages like ALGOL do this for you, array bounds can be variables).

What I need to know is whether the C compiler mucks around with the
stack pointer at times other than procedure linkage and local variable
space allocation, i.e. at times other than procedure entry/exit. Does it,
for example, change the stack pointer to allocate register spill space
during complex expression evaauation? Does anyone know? Thanks.

				    - Eric Holstege
				    (eric at cit-vax)
				    (...ucbvax!cithep!citcsv!eric)



More information about the Comp.unix.wizards mailing list