Re: [PATCH/RFC 02/11] strbuf: add non-variadic function strbuf_vaddf()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 26, 2009, 00:59 UTC
- Message-ID
- <7vskc2ksnn.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1259196260-3064-3-git-send-email-kusmabite@gmail.com>
Erik Faye-Lund <kusmabite@googlemail.com> writes:
Show 15 quoted lines
> +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()?