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

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

 



On Sun, Sep 09, 2007 at 09:41:24AM +0000, René Scharfe wrote:
> 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

  Oh boy, exactly I meant pos = sb->len (see the comment in strbuf.h).
I'll fix that.

> 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);
> > +}
> 

-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpPbdOkTO2wj.pgp
Description: PGP signature


[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