[ale] OT: C not C++ Question

Danny Cox danscox at mindspring.com
Mon Dec 30 13:07:28 EST 2002


Chuck,

On Mon, 2002-12-30 at 12:40, Chuck Huber wrote:
> One thing to keep in mind though with alloca - if you have it in a loop
> you could easily run out of stack space.  If I recall correctly, your
> user-level apps have 4k of stack space for each process.
> 
> I'm not familiar with the alloca() stuff and don't know if there's a
> freea().  I'm not sure one could be implemented after considering:
> 
>     ptr1 = alloca(...);   // uses stack space
>     ptr2 = alloca(...);   // uses more stack space
>     freea(ptr1);          // How can you free a block on the
>                           // stack that's underneath some other block?
> 

	Nope, you can't do that.  However, with the Spencer alloca, you're not
using stack space anyway, as it actually calls malloc.

	Now, you can't just hand the pointer you got from the Spencer alloca to
free, either.  The results would be, uh, indeterminate..., yeah, that's
a good word (nudge, nudge, wink, wink).

	See my earlier post today on how the Spencer alloca worked.

	I'm almost beginning to regret having brought this up in the first
place.  It's caused 'way too much explanation already ;-).

	What I meant to do was point Chris (and interested others) to the
Spencer alloca code, form their own ideas on how it worked, if it would
work for their project, and then roll their own.  What was I
thinking?!?! ;-)

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list