Alloca Wars: Another View

Richard A. O'Keefe ok at quintus.uucp
Tue Aug 9 13:52:56 AEST 1988


In article <895 at vsi1.UUCP> bitbug at 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...]



More information about the Comp.lang.c mailing list