Add a printbuf_memset() function to provide an effecient way to set and append things like whitespace indentation.

This commit is contained in:
Eric Haszlakiewicz
2012-04-02 15:39:55 -05:00
parent 781798ccdf
commit 2d48543f2e
2 changed files with 58 additions and 10 deletions

View File

@@ -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, ...);