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
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to