Re: [PATCH] Rework strbuf API and semantics.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 4 Sep 2007, Pierre Habouzit wrote:

> +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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux