Re: [PATCH 1/6] Add strbuf_rtrim and strbuf_insert.

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

 



Pierre Habouzit schrieb:
> +void strbuf_insert(struct strbuf *sb, size_t pos, const void *data, size_t len) {
> +	strbuf_grow(sb, len);
> +	if (pos >= sb->len) {
> +		sb->len = pos;

Did you mean "pos = sb->len;", i.e. append without creating a hole in
the string?  The statement as is has no effect because sb->len is not
used until the strbuf_setlen() at the end.

> +	} else {
> +		memmove(sb->buf + pos + len, sb->buf + pos, sb->len - pos);
> +	}
> +	memcpy(sb->buf + pos, data, len);
> +	strbuf_setlen(sb, sb->len + len);
> +}

-
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