alloca wars

Jeff Barr jeff at amsdsg.UUCP
Thu Aug 4 03:14:31 AEST 1988


Correct me if I'm wrong.  The benefits of alloca() over malloc() are:

(1)  There is no need for the program to explicitly free the storage 
     allocated via alloca(), as the free() is implicit at the end of the 
     scope which encloses the alloca call.  (Actually implemented by
     adjusting the frame pointer at the end of the scope in a true
     alloca implementation.)

(2)  The memory arena used by malloc() is not referenced by alloca (), 
     bypassing any possible fragmentation problems.
 
-- 
						Jeff
	+---------------------------------------------------------+
	|  Jeff Barr   AMS-DSG   uunet!amsdsg!jeff   800-832-8668 |
	+---------------------------------------------------------+



More information about the Comp.lang.c mailing list