2015-07-22 14:48 GMT+02:00 Ron Yorston <[email protected]>:
> 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

Thanks for the explanation. Now I have read and understand more about
setjmp. Didn't know it was used to implement an exception handler...
Shell parsing is hell! :S

Cheers,

Xabier Oneca_,,_
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to