Re: Runtime stack allocation
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: 30 Jun 2008 08:52:34 -0700
kid joe <spamtrap@xxxxxxxxxxxxxxxx> writes:
I'm using a temporary buffer to transfer some data and would rather[...]
not allocate it on the heap. The problem is that the size of the
buffer is only known upon entry into the function that utilizes it and
I'd rather not waste space or dynamically allocate on the heap (since
it doesn't need to persist). Now I'm planning on utilizing inline
assembly to modify the stack pointer directly to allocate the space I
need.
My advice: allocate it using malloc() (on the "heap") anyway, and call
free() when you're done with it.
There is no portable and reliable way to do temporary allocations on
the "stack". (The C standard doesn't even guarantee that there is a
"stack" in the sense you probably mean.)
By using assembly language, you limit yourself to a single platform.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- Runtime stack allocation
- From: kid joe
- Runtime stack allocation
- Prev by Date: Re: Promoting unsigned long int to long int
- Next by Date: Re: Newbie Question about multiple system calls within loops
- Previous by thread: Re: Runtime stack allocation
- Next by thread: Re: Runtime stack allocation
- Index(es):
Relevant Pages
|