From: Dmitry V. Levin Date: Tue, 23 May 2006 11:28:54 GMT Subject: Q: xasprintf Message-ID: <20060523112854.GD5582@basalt.office.altlinux.org> In-Reply-To: <7vzmh98seo.fsf@assigned-by-dhcp.cox.net> Hi, On Mon, May 22, 2006 at 06:02:39PM -0700, Junio C Hamano wrote: > Sean writes: [...] > > - name = xmalloc(len_a + len_b - pfx_length - sfx_length + 7); > > + name = xmalloc(pfx_length + a_midlen + b_midlen + sfx_length + 7); > > sprintf(name, "%.*s{%.*s => %.*s}%s", > > Obviously correct given what the sprintf() that immediately > follows does. Sheesh, what was I smoking back then. *BLUSH* What about introducing xasprintf() to eliminate such issues? -- ldv