httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@worldgate.com>
Subject Re: alloca (was Re: cvs commit: apache-1.3/src/modules/standard mod_log_referer.c)
Date Mon, 25 May 1998 01:45:05 GMT
On Sun, 24 May 1998, Dean Gaudet wrote:

> alloca essentially has to use compiler-dependant features... it's either
> implemented as a builtin (as it is in gcc), or using extensions (like
> inline assembly, which is how it's done in WATCOM C). 

/usr/src/contrib/gcc/alloca.c:

/* alloca.c -- allocate automatically reclaimed memory
   (Mostly) portable public-domain implementation -- D A Gwyn

   This implementation of the PWB library alloca function,
   which is used to allocate space off the run-time stack so
   that it is automatically reclaimed upon procedure exit,
   was inspired by discussions with J. Q. Johnson of Cornell.
   J.Otto Tennant <jot@cray.com> contributed the Cray support.

   There are some preprocessor constants that can
   be defined when compiling for your specific system, for
   improved efficiency; however, the defaults should be okay.

   The general concept of this implementation is to keep
   track of all alloca-allocated blocks, and reclaim any
   that are found to be deeper in the stack than the current
   invocation.  This heuristic does not reclaim storage as
   soon as it becomes invalid, but it will do so eventually.

   As a special case, alloca(0) reclaims storage without
   allocating any.  It is a good idea to use alloca(0) in
   your main control loop, etc. to force garbage collection.  */

This is from the FreeBSD gcc 2.7.2.1 source.  It is using malloc and free.
There are processor specific assembly implementations, but does gcc have
them for every processor or does it use the malloc/free one for some?  



Mime
View raw message