2015-07-22 14:29 GMT+02:00 Laurent Bercot <ska-dietl...@skarnet.org>: > 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.
So, generated code is smaller and faster with alloca, but at a possible cost of stability? > 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. For what I read, VLAs are not safer than alloca... Thanks, Xabier Oneca_,,_ _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox