Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!vsi1!bitbug@vsi1 From: bitbug@vsi1 (James Buster) Newsgroups: comp.lang.c Subject: Alloca Wars: Another View Summary: Why use alloca? longjmp(). Keywords: alloca longjmp Message-ID: <895@vsi1.UUCP> Date: 8 Aug 88 21:03:56 GMT Sender: news@vsi1.UUCP Reply-To: bitbug@vsi1 (James Buster) Organization: Vicom Systems, Inc. Lines: 10 There is one reason to use alloca: longjmp. Code in which it is possible to longjmp out of may not work when using malloc as the memory allocator of choice, since the corresponding free may never be called, wasting memory and perhaps causing your program to crash. Longjmp works by restoring a previous stack frame, and deleting the present one (which includes any memory allocated by alloca). Thus, programs which tend to use longjmp a lot (shells, text editors, etc) will probably work better and more reliably with alloca than malloc. -- --