[tremor] Re: good version of alloca()

Monty xiphmont at xiph.org
Mon Oct 14 14:57:33 PDT 2002



On Tue, Oct 15, 2002 at 01:10:34AM +0200, Dimitry Andric wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 2002-10-14 at 18:23:52 timmy brolin wrote:
> 
> tb> Can alloca() be replaced by malloc() and free ?
> tb> That'd be a nice patch sine many dev systems don't include alloca().
> 
> Well, this might not be so simple as it sounds. The reason is that
> allocations made using alloca() don't need to be freed explicitly, as
> is the case with malloc(). They are implicitly freed when a function
> exits and its stack is popped.

Actually, the real reason to use alloca is that it's about three asm
opcodes, can be inlined trivially, requires no system call, will not
add to heap fragmentation, etc, etc.  It is the fast way to get
temporary storage.  very fast.  

Monty
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'tremor-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Tremor mailing list