Skip to content

Commit efbf09b

Browse files
committed
Merge branch 'rs/use-strbuf-addbuf' into next
* rs/use-strbuf-addbuf: strbuf: avoid calling strbuf_grow() twice in strbuf_addbuf()
2 parents d39c827 + 31471ba commit efbf09b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

strbuf.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ void strbuf_add(struct strbuf *sb, const void *data, size_t len)
197197
strbuf_setlen(sb, sb->len + len);
198198
}
199199

200+
void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2)
201+
{
202+
strbuf_grow(sb, sb2->len);
203+
memcpy(sb->buf + sb->len, sb2->buf, sb2->len);
204+
strbuf_setlen(sb, sb->len + sb2->len);
205+
}
206+
200207
void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len)
201208
{
202209
strbuf_grow(sb, len);

strbuf.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,7 @@ static inline void strbuf_addstr(struct strbuf *sb, const char *s)
263263
/**
264264
* Copy the contents of another buffer at the end of the current one.
265265
*/
266-
static inline void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2)
267-
{
268-
strbuf_grow(sb, sb2->len);
269-
strbuf_add(sb, sb2->buf, sb2->len);
270-
}
266+
extern void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2);
271267

272268
/**
273269
* Copy part of the buffer from a given position till a given length to the

0 commit comments

Comments
 (0)