From owner-freebsd-audit Tue Dec 19 17:42:43 2000 From owner-freebsd-audit@FreeBSD.ORG Tue Dec 19 17:42:41 2000 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id D930B37B404; Tue, 19 Dec 2000 17:42:39 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_18979)/8.9.3) with ESMTP id MAA06496; Wed, 20 Dec 2000 12:42:36 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37640) with ESMTP id <01JXXEOQZE0G902KLJ@cim.alcatel.com.au>; Wed, 20 Dec 2000 12:42:34 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.0/8.11.0) id eBK1gWF63786; Wed, 20 Dec 2000 12:42:32 +1100 (EST envelope-from jeremyp) Content-return: prohibited Date: Wed, 20 Dec 2000 12:42:32 +1100 From: Peter Jeremy Subject: Re: printf(1) broken for some long format strings In-reply-to: <20001219215413.H78749@strontium.scientia.demon.co.uk>; from ben@FreeBSD.ORG on Tue, Dec 19, 2000 at 09:54:14PM +0000 To: Ben Smithurst Cc: audit@FreeBSD.ORG Mail-followup-to: Ben Smithurst , audit@FreeBSD.ORG Message-id: <20001220124232.I54775@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <20001219143506.C78749@strontium.scientia.demon.co.uk> <200012191729.eBJHTps36903@billy-club.village.org> <20001219215413.H78749@strontium.scientia.demon.co.uk> Sender: jeremyp@gsmx07.alcatel.com.au Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Dec-19 21:54:14 +0000, Ben Smithurst 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