summaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-25 14:13:47 -0700
committerJunio C Hamano <gitster@pobox.com>2016-07-25 14:13:47 -0700
commitb4e8a847ba4e775fb7d422b2daf18356db50eec8 (patch)
treeb7beddae0b6b9800c8a40dfc6b4be33764b6a4a6 /strbuf.c
parent7b01ab562ae14f5e5aedf0c0e769c74925a19809 (diff)
parent31471ba21ee29886ab856981e52f723c913d7f40 (diff)
downloadgit-b4e8a847ba4e775fb7d422b2daf18356db50eec8.tar.gz
Merge branch 'rs/use-strbuf-addbuf'
Code cleanup. * rs/use-strbuf-addbuf: strbuf: avoid calling strbuf_grow() twice in strbuf_addbuf() use strbuf_addbuf() for appending a strbuf to another
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index 1ba600bd78..f3bd5719c6 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -197,6 +197,13 @@ void strbuf_add(struct strbuf *sb, const void *data, size_t len)
strbuf_setlen(sb, sb->len + len);
}
+void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2)
+{
+ strbuf_grow(sb, sb2->len);
+ memcpy(sb->buf + sb->len, sb2->buf, sb2->len);
+ strbuf_setlen(sb, sb->len + sb2->len);
+}
+
void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len)
{
strbuf_grow(sb, len);