strbuf: export strbuf_addchars()
authorRené Scharfe <l.s.r@web.de>
Sun, 7 Sep 2014 07:03:32 +0000 (09:03 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Sep 2014 18:26:45 +0000 (11:26 -0700)
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>
Documentation/technical/api-strbuf.txt
strbuf.c
strbuf.h
utf8.c
index 3350d97dda2408f92dc44c1e3216facc50257a50..1d8336211664be114925a7b55ddd988908cc8bf8 100644 (file)
@@ -142,6 +142,10 @@ then they will free() it.
 
        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
index 1170d01c4322b494cd900853279766edd030de32..5e44cf9204a5845cc001a6b0fbd63f436fde7673 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -196,6 +196,13 @@ void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len)
        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;
index 73e80cea69b5e2965cf4ce8c36444f45aae8e19c..2c34753a6877bfdbb851d50436f10c2626f57716 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -121,6 +121,7 @@ static inline void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2) {
        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 0d20e0acb2b6fb2dd1d63abed676a036b2b7ec2f..c55f3ba0bc96c0993d4bae7f45fb00539c44d1c1 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -302,13 +302,6 @@ int is_utf8(const char *text)
        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)
 {