Path: utzoo!utgpu!attcan!uunet!amsdsg!jeff From: jeff@amsdsg.UUCP (Jeff Barr) Newsgroups: comp.lang.c Subject: Re: alloca wars Summary: alloca benefits Keywords: alloca memory allocation Message-ID: <156@amsdsg.UUCP> Date: 3 Aug 88 17:14:31 GMT References: <3950010@eecs.nwu.edu> <62170@sun.uucp> <62363@sun.uucp> <8301@smoke.ARPA> Organization: AMS Departmental Systems Group, Arlington, VA Lines: 17 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 | +---------------------------------------------------------+