[PATCH 1/2] Revert "ash: use alloca to get rid of setjmp"

Ron Yorston rmy at pobox.com
Wed Jul 22 12:48:42 UTC 2015


Xabier Oneca wrote:
>I'm not an expert, but why not just use plain ol' malloc?

That's what the code in question did originally.

This is in the shell parser which is recursive and has to allow errors
to propagate upwards.  The code in this case had setjmp/longjmp calls
to avoid leaking allocated memory when a parse error was detected at a
lower level.  This made the code more obscure (and bigger!).

Using alloca allows the memory to be freed automatically when the function
returns and results in simpler (and smaller!) code.

Ron


More information about the busybox mailing list