On 22/07/2015 13:46, Xabier Oneca -- xOneca wrote:
I've read alloca is not portable anyways...

 It's probably portable on every platform busybox is running on.
(I'm not advertising its use, just saying I don't think it's the
right argument for not using it.)


I'm not an expert, but why not just use plain ol' malloc?

 malloc uses the heap. It's more complicated, pulls in more code,
takes more time to run, and requires manual management; whereas
alloca and VLAs use the stack, which is smaller, simpler and faster.
 For a minimalistic piece of software such as busybox, it makes
sense to avoid using the heap when it can be avoided.

 I don't use alloca, but I'm a big fan of VLAs; they save me lots
of calls to malloc, and a good portion of the programs I write
don't use the heap at all (which is a nice way to ensure they will
never leak memory). However, like Denys, I thought that programs
simply crashed when the kernel couldn't allocate them enough stack;
on MMU systems, there's no reason why the kernel can't enforce a
bound, or simply let the stack run unbounded.
 Rich (or anyone), any good pointers to read about this ?

--
 Laurent
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to