Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucbvax!decwrl!labrea!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Alloca Wars: Another View Keywords: alloca longjmp Message-ID: <261@quintus.UUCP> Date: 9 Aug 88 03:52:56 GMT References: <895@vsi1.UUCP> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 15 In article <895@vsi1.UUCP> bitbug@vsi1 (James Buster) writes: >There is one reason to use alloca: longjmp. There are a lot of other things one might want to clean up as well, such as closing and unlinking scratch files, free()ing malloc()ed blocks which _couldn't_ be allocated with alloca() because they were to be returned to the caller if all went well, ... The answer is to put together something like Lisp's (unwind-protect ...), not to introduce special alloca(), fopena(), &c functions. In an editor (one of Buster's examples) you might well want to undo changes to the buffer made since the transaction started. And so it goes. Freeing memory blocks which can only be used locally is the least of one's worries. Now, what's a good way to do something like (unwind-protect ...) in C? [And people wonder why I read comp.lang.ada...]