Re: [PATCH 1/4] strbuf: add strbuf_add_uint()
- From
Jeff King <peff@peff.net>
- Date
- May 13, 2026, 16:47 UTC
- Message-ID
- <20260513164722.GD103037@coredump.intra.peff.net>
- In-Reply-To
- <20260513162232.GB103037@coredump.intra.peff.net>
On Wed, May 13, 2026 at 12:22:32PM -0400, Jeff King wrote:
Show 10 quoted lines
> void strbuf_add_uint(struct strbuf *sb, uintmax_t value)
> {
> - char buf[DIV_ROUND_UP(bitsizeof(value) * 10, 33)];
> - char *end = buf + sizeof(buf);
> - char *p = end;
> + unsigned digits = decimal_length_u64(value);
> + char *p;
>
> + strbuf_grow(sb, digits);
> + p = sb->buf + digits;This last line should be "sb->buf + sb->len + digits", of course. Naturally that was the part I wrote by hand. ;)
It doesn't matter for the cat-file test, since we're always formatting into an empty buffer, but it does for the ls-files padding one.
-Peff