summaryrefslogtreecommitdiff
path: root/printbuf.h
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2012-04-02 15:39:55 -0500
committerEric Haszlakiewicz <erh+git@nimenees.com>2012-04-02 15:39:55 -0500
commit2d48543f2ef8caadcbdbd9b3b779664038bf6a2b (patch)
treeafe71c9e3126edb49313edfe1ea3d699d2f67a48 /printbuf.h
parent781798ccdfbe56abd5046d3978e29adf10c74c23 (diff)
downloadjson-c-2d48543f2ef8caadcbdbd9b3b779664038bf6a2b.tar.gz
Add a printbuf_memset() function to provide an effecient way to set and append things like whitespace indentation.
Diffstat (limited to 'printbuf.h')
-rw-r--r--printbuf.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/printbuf.h b/printbuf.h
index 5d4963f..fc8ac61 100644
--- a/printbuf.h
+++ b/printbuf.h
@@ -50,6 +50,19 @@ do { \
} else { printbuf_memappend(p, (bufptr), bufsize); } \
} while (0)
+#define printbuf_length(p) ((p)->bpos)
+
+/**
+ * Set len bytes of the buffer to charvalue, starting at offset offset.
+ * Similar to calling memset(x, charvalue, len);
+ *
+ * The memory allocated for the buffer is extended as necessary.
+ *
+ * If offset is -1, this starts at the end of the current data in the buffer.
+ */
+extern int
+printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
+
extern int
sprintbuf(struct printbuf *p, const char *msg, ...);