From: Junio C Hamano Date: Thu, 26 Nov 2009 00:59:24 GMT Subject: Re: [PATCH/RFC 02/11] strbuf: add non-variadic function strbuf_vaddf() Message-ID: <7vskc2ksnn.fsf@alter.siamese.dyndns.org> In-Reply-To: <1259196260-3064-3-git-send-email-kusmabite@gmail.com> Erik Faye-Lund writes: > +void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap) > { > int len; > > if (!strbuf_avail(sb)) > strbuf_grow(sb, 64); > len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); > if (len < 0) > die("your vsnprintf is broken"); > if (len > strbuf_avail(sb)) { > strbuf_grow(sb, len); > len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); > if (len > strbuf_avail(sb)) { > die("this should not happen, your snprintf is broken"); > } Hmm, I would have expected to see va_copy() somewhere in the patch text. Is it safe to reuse ap like this in two separate invocations of vsnprintf()?