Date: Tue, 19 Dec 2000 10:29:51 -0700 From: Warner Losh <imp@village.org> To: Ben Smithurst <ben@FreeBSD.ORG> Cc: audit@FreeBSD.ORG Subject: Re: printf(1) broken for some long format strings Message-ID: <200012191729.eBJHTps36903@billy-club.village.org> In-Reply-To: Your message of "Tue, 19 Dec 2000 14:35:06 GMT." <20001219143506.C78749@strontium.scientia.demon.co.uk> References: <20001219143506.C78749@strontium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <20001219143506.C78749@strontium.scientia.demon.co.uk> Ben Smithurst writes: : + if (len > copy_size) { : + if ((newcopy = realloc(copy, len)) == NULL) : + return NULL; : + copy = newcopy; : + copy_size = len; : + } if (len > copy_size) { if (copy_size == 0) newlen = 1024; else newlen = ((len + 1023) >> 10) << 10; if ((newcopy = realloc(copy, newlen)) == NULL) return NULL; copy = newcopy; copy_size = newlen; } might be a little better. It will round the size to the next highest k boundary, which will result in fewer malloc calls. A slightly better way would be to find some way to round it up to the next power of 2 so that you do even fewer malloc calls, but my bit tiddling foo isn't awake yet this morning. Warner 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?200012191729.eBJHTps36903>