strbuf: export strbuf_addchars()
Move strbuf_addchars() to strbuf.c, where it belongs, and make it
available for other callers.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt
index 3350d97..1d83362 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -142,6 +142,10 @@
Add a single character to the buffer.
+`strbuf_addchars`::
+
+ Add a character the specified number of times to the buffer.
+
`strbuf_insert`::
Insert data to the given position of the buffer. The remaining contents
diff --git a/strbuf.c b/strbuf.c
index 1170d01..5e44cf9 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -196,6 +196,13 @@
strbuf_setlen(sb, sb->len + len);
}
+void strbuf_addchars(struct strbuf *sb, int c, size_t n)
+{
+ strbuf_grow(sb, n);
+ memset(sb->buf + sb->len, c, n);
+ strbuf_setlen(sb, sb->len + n);
+}
+
void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
{
va_list ap;
diff --git a/strbuf.h b/strbuf.h
index 73e80ce..2c34753 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -121,6 +121,7 @@
strbuf_add(sb, sb2->buf, sb2->len);
}
extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
+extern void strbuf_addchars(struct strbuf *sb, int c, size_t n);
typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, void *context);
diff --git a/utf8.c b/utf8.c
index 0d20e0a..c55f3ba 100644
--- a/utf8.c
+++ b/utf8.c
@@ -302,13 +302,6 @@
return 1;
}
-static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
-{
- strbuf_grow(sb, n);
- memset(sb->buf + sb->len, c, n);
- strbuf_setlen(sb, sb->len + n);
-}
-
static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
int indent, int indent2)
{