On Fri, Jul 30, 2010 at 03:26:25 +0200, Denys Vlasenko wrote: > On Tuesday 27 July 2010 16:21, Alexander Shishkin wrote: > > Since "sizeof buffer" won't work with dynamically allocated buffers, > > and we still sometimes need to know the size of the whole buffer, we > > need a way to always obtain said size. > > In almost all cases, allocating on heap is the best anyway. > Maybe we should just gradually move to it and get rid of this > three-way configurability? There is a bug in fdisk somewhere which > only triggers with on-stack allocation IIRC, that's the price > for having a rarely tested config... > > Do I miss why on-stack alloc may be better that malloc > for some users? Is it NOMMU?
Well, on-stack allocation is cheaper since it doesn't require any extra calls in userspace. In a situation with heavy memory pressure, you might well end up having malloc() returning NULL, which will lead to busybox exiting, whereas with onstack allocation you it will trigger OOM killer which is likely to kill something else. Other than that, I would actually vouch for BSS allocation, which also has the benefit of being done only once when the binary is loaded. Regards, -- Alex _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
