use of alloca ?

Alexandre Oliva oliva at dcc.unicamp.br
Sat Jan 30 12:19:11 PST 1999


On Jan 30, 1999, Christopher Smith <cbsmith at envise.com> wrote:

> On Sat, 30 Jan 1999, Prashanth K.S. wrote:

>> can alloca be replaced by malloc (& free before function exit). If not, 
>> can something else be used instead of it to achieve the same effect ?

> So, it's a performance optimization, but it's a good idea to use it
> wherever possible.

Except that it isn't ANSI C, and so it is not portable and is not
available in many implementations of C.  And yes, there is a
reasonably portable implementation that, unfortunately, does not work
in multi-threaded applications, because it relies on the stack pointer
to find out whether it can deallocate a memory region or not.

-- 
Alexandre Oliva  http://www.dcc.unicamp.br/~oliva  aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil



More information about the kaffe mailing list