Commit 32016d15 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a couple of macros for safely (assertedly) printing into a

static sized buffer.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4458 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 8824e1c0
......@@ -133,3 +133,17 @@ do { \
abort(); \
} while (0)
const char* svn_version(void);
/* Safe printf into a fixed-size buffer */
#define bprintf(buf, fmt, ...) \
do { \
assert(snprintf(buf, sizeof buf, fmt, __VA_ARGS__) \
< sizeof buf); \
} while (0)
/* Safe printf into a fixed-size buffer */
#define vbprintf(buf, fmt, ap) \
do { \
assert(vsnprintf(buf, sizeof buf, fmt, ap) \
< sizeof buf); \
} while (0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment