aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/strbuf.c9
-rw-r--r--tools/perf/util/strbuf.h7
2 files changed, 9 insertions, 7 deletions
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index d3d279275432..8fb73295ec34 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -51,6 +51,13 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
51 ALLOC_GROW(sb->buf, sb->len + extra + 1, sb->alloc); 51 ALLOC_GROW(sb->buf, sb->len + extra + 1, sb->alloc);
52} 52}
53 53
54void strbuf_addch(struct strbuf *sb, int c)
55{
56 strbuf_grow(sb, 1);
57 sb->buf[sb->len++] = c;
58 sb->buf[sb->len] = '\0';
59}
60
54void strbuf_add(struct strbuf *sb, const void *data, size_t len) 61void strbuf_add(struct strbuf *sb, const void *data, size_t len)
55{ 62{
56 strbuf_grow(sb, len); 63 strbuf_grow(sb, len);
@@ -58,7 +65,7 @@ void strbuf_add(struct strbuf *sb, const void *data, size_t len)
58 strbuf_setlen(sb, sb->len + len); 65 strbuf_setlen(sb, sb->len + len);
59} 66}
60 67
61void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap) 68static void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
62{ 69{
63 int len; 70 int len;
64 va_list ap_saved; 71 va_list ap_saved;
diff --git a/tools/perf/util/strbuf.h b/tools/perf/util/strbuf.h
index b73cbaaf93bc..ab9be0fbbd40 100644
--- a/tools/perf/util/strbuf.h
+++ b/tools/perf/util/strbuf.h
@@ -71,11 +71,7 @@ static inline void strbuf_setlen(struct strbuf *sb, size_t len) {
71} 71}
72 72
73/*----- add data in your buffer -----*/ 73/*----- add data in your buffer -----*/
74static inline void strbuf_addch(struct strbuf *sb, int c) { 74void strbuf_addch(struct strbuf *sb, int c);
75 strbuf_grow(sb, 1);
76 sb->buf[sb->len++] = c;
77 sb->buf[sb->len] = '\0';
78}
79 75
80void strbuf_add(struct strbuf *buf, const void *, size_t); 76void strbuf_add(struct strbuf *buf, const void *, size_t);
81static inline void strbuf_addstr(struct strbuf *sb, const char *s) { 77static inline void strbuf_addstr(struct strbuf *sb, const char *s) {
@@ -84,7 +80,6 @@ static inline void strbuf_addstr(struct strbuf *sb, const char *s) {
84 80
85__attribute__((format(printf,2,3))) 81__attribute__((format(printf,2,3)))
86void strbuf_addf(struct strbuf *sb, const char *fmt, ...); 82void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
87void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap);
88 83
89/* XXX: if read fails, any partial read is undone */ 84/* XXX: if read fails, any partial read is undone */
90ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint); 85ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint);