Re: [PATCH 3/5] Add strbuf_printf() to do formatted printing to a strbuf.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 31, 2007, 04:36 UTC
- Message-ID
- <7vhcnlgpeo.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <11858309322006-git-send-email-krh@redhat.com>
Kristian Høgsberg <krh@redhat.com> writes:
Show 6 quoted lines
> +static void inline strbuf_grow(struct strbuf *sb, size_t extra)
> +{
> + while (sb->alloc < sb->len + extra)
> sb->alloc = sb->alloc * 3 / 2 + 16;
> + sb->buf = xrealloc(sb->buf, sb->alloc);
> +}Somehow this while () loop to compute the growth factor bothers me but that is probably a minor detail.
Show 5 quoted lines
> +void strbuf_printf(struct strbuf *sb, const char *fmt, ...)
> +{
> + char one_line[2048];
> + va_list args;
> + int len;Such a nice abstraction so far, and then at the highest level of callchain we have this hardcoded limit?