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>
René Scharfe committed
Sep 7, 2014 at 09:03 UTC
d07235a027e0c7ed2fee1aeb3bee8a858bf5ca58
4 files changed
+12
-7
Documentation/technical/api-strbuf.txt
+4
@@ -142,6 +142,10 @@ then they will free() it.
142
143
Add a single character to the buffer.
144
145
+`strbuf_addchars`::
146
+
147
+ Add a character the specified number of times to the buffer.
148
+
149
`strbuf_insert`::
150
151
Insert data to the given position of the buffer. The remaining contents
strbuf.c
+7
@@ -196,6 +196,13 @@ void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len)
196
strbuf_setlen(sb, sb->len + len);
197
}
198
199
+void strbuf_addchars(struct strbuf *sb, int c, size_t n)
200
+{
201
+ strbuf_grow(sb, n);
202
+ memset(sb->buf + sb->len, c, n);
203
+ strbuf_setlen(sb, sb->len + n);
204
+}
205
+
206
void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
207
{
208
va_list ap;
strbuf.h
+1
@@ -121,6 +121,7 @@ static inline void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2) {
121
strbuf_add(sb, sb2->buf, sb2->len);
122
}
123
extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
124
+extern void strbuf_addchars(struct strbuf *sb, int c, size_t n);
125
126
typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
127
extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, void *context);
utf8.c
-7
@@ -302,13 +302,6 @@ int is_utf8(const char *text)
302
return 1;
303
}
304
305
-static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
306
-{
307
- strbuf_grow(sb, n);
308
- memset(sb->buf + sb->len, c, n);
309
- strbuf_setlen(sb, sb->len + n);
310
-}
311
-
305
static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
306
int indent, int indent2)
307
{