aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/strbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/strbuf.c')
-rw-r--r--tools/perf/util/strbuf.c24
1 files changed, 0 insertions, 24 deletions
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 25671fa16618..d3d279275432 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -51,30 +51,6 @@ 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
54static void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
55 const void *data, size_t dlen)
56{
57 if (pos + len < pos)
58 die("you want to use way too much memory");
59 if (pos > sb->len)
60 die("`pos' is too far after the end of the buffer");
61 if (pos + len > sb->len)
62 die("`pos + len' is too far after the end of the buffer");
63
64 if (dlen >= len)
65 strbuf_grow(sb, dlen - len);
66 memmove(sb->buf + pos + dlen,
67 sb->buf + pos + len,
68 sb->len - pos - len);
69 memcpy(sb->buf + pos, data, dlen);
70 strbuf_setlen(sb, sb->len + dlen - len);
71}
72
73void strbuf_remove(struct strbuf *sb, size_t pos, size_t len)
74{
75 strbuf_splice(sb, pos, len, NULL, 0);
76}
77
78void strbuf_add(struct strbuf *sb, const void *data, size_t len) 54void strbuf_add(struct strbuf *sb, const void *data, size_t len)
79{ 55{
80 strbuf_grow(sb, len); 56 strbuf_grow(sb, len);