Date: Wed, 20 Dec 2000 12:42:32 +1100 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: Ben Smithurst <ben@FreeBSD.ORG> Cc: audit@FreeBSD.ORG Subject: Re: printf(1) broken for some long format strings Message-ID: <20001220124232.I54775@gsmx07.alcatel.com.au> In-Reply-To: <20001219215413.H78749@strontium.scientia.demon.co.uk>; from ben@FreeBSD.ORG on Tue, Dec 19, 2000 at 09:54:14PM %2B0000 References: <20001219143506.C78749@strontium.scientia.demon.co.uk> <200012191729.eBJHTps36903@billy-club.village.org> <20001219215413.H78749@strontium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2000-Dec-19 21:54:14 +0000, Ben Smithurst <ben@FreeBSD.ORG> wrote: >Warner Losh wrote: >Why not just use > >> newlen = ((len + 1023) >> 10) << 10; > >every time? That would seem the better solution. >> might be a little better. It will round the size to the next highest >> k boundary, which will result in fewer malloc calls. > >that's probably over the top, since the maximum length before this >change was 64 bytes, there can't be many places where more than that is >needed or someone would have noticed this and fixed it before me. :-) One problem with your patch is that it just ensures that there is sufficient space for the current copy. This means that realloc() is likely to be called a number of times with slightly larger lengths each time. This sort of behaviour is likely to lead to memory fragmentation, which may be significant in long running processes (like interactive shells). Over-estimating the amount of memory needed when actually allocating memory will reduce the number of realloc()s and hence the amount of fragmentation. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001220124232.I54775>