summaryrefslogtreecommitdiffstats
path: root/membuffer.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2015-01-24 12:47:26 +1200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-15 06:02:24 -0800
commit3521cdcbd6bb2e282249286afe16b066e4af30e8 (patch)
treec7055dd4ca7069ba357ca78d51aa5501cfb330b7 /membuffer.h
parent6397d56af4a6eccf9b2ed748499fe891dcdb64b1 (diff)
downloadsubsurface-3521cdcbd6bb2e282249286afe16b066e4af30e8.tar.gz
membuffer: add helper functions to return regular C strings
The whole "create a string using a printf-like interface" thing is pretty common, and most users then don't necessarily want to deal with the membuffer interfaces around it. So this just creates trivial wrappers to do this, so that you can do s = format_string("%d: %s\n", i, str); or similar things. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'membuffer.h')
-rw-r--r--membuffer.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/membuffer.h b/membuffer.h
index c0a4f6029..434b34c71 100644
--- a/membuffer.h
+++ b/membuffer.h
@@ -18,6 +18,7 @@ struct membuffer {
#define __printf(x, y)
#endif
+extern char *detach_buffer(struct membuffer *b);
extern void free_buffer(struct membuffer *);
extern void flush_buffer(struct membuffer *, FILE *);
extern void put_bytes(struct membuffer *, const char *, int);
@@ -30,6 +31,11 @@ extern __printf(2, 3) void put_format(struct membuffer *, const char *fmt, ...);
extern __printf(2, 0) char *add_to_string_va(const char *old, const char *fmt, va_list args);
extern __printf(2, 3) char *add_to_string(const char *old, const char *fmt, ...);
+/* Helpers that use membuffers internally */
+extern __printf(1, 0) char *vformat_string(const char *, va_list);
+extern __printf(1, 2) char *format_string(const char *, ...);
+
+
/* Output one of our "milli" values with type and pre/post data */
extern void put_milli(struct membuffer *, const char *, int, const char *);