Re: [PATCH] Rework strbuf API and semantics.
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Sep 4, 2007, 15:44 UTC
- Message-ID
- <Pine.LNX.4.64.0709041642350.28586@racer.site>
- In-Reply-To
- <11889144741644-git-send-email-madcoder@debian.org>
Hi,
On Tue, 4 Sep 2007, Pierre Habouzit wrote:
Show 7 quoted lines
> +void strbuf_grow(struct strbuf *sb, size_t extra) {
> + if (sb->len + extra + STRBUF_GROW_STEP < sb->len)
> + die("you want to use way to much memory");
> +
> + sb->alloc = ((sb->len + extra) + STRBUF_GROW_STEP) & ~(STRBUF_GROW_STEP - 1);
> + sb->buf = xrealloc(sb->buf, sb->alloc);
> +}Why not use ALLOC_GROW()? Seems to me more efficient than growing by 1kB blocks all the time, for big strings as for short strings.
Ciao, Dscho