[vox-tech] dyanamic memory panacea

Peter Jay Salzman vox-tech@lists.lugod.org
Tue, 16 Jul 2002 12:30:17 -0700


ok, not a panacea, but pretty cool nevertheless...

i was doing some reading and found a function alloca() which allocates
dynamic memory like malloc() and friends, but it gets memory from the
current stack frame instead of the heap.

the obvious advantage is that the memory is deallocated once the stack
frame is popped.  in other words, when the function returns, all memory
allocated by alloca is freed.  this means no memory leaks.  very cool.

however, in the man page, under BUGS, it says:

BUGS
       The alloca function is machine dependent.

this doesn't say anything to me.  what does it mean for a function to be
machine dependent?   does it behave differently across different
machine architectures?  does code compiled on one x86 machine not run on
another x86 machine?

what exactly is the man page warning me about?

pete

-- 
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D