X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fsnprintf.c;h=ad04a02e23a7230419a869dfcd67e8448944409d;hb=e0b813f4802ce167188d501761ec6648edcc5649;hp=693a2592e80fb9c591b8982be6032b60dc5c93a9;hpb=1fa6e9def6d5eb1e85a4a24af9d49a5b82951d22;p=citadel.git diff --git a/citadel/snprintf.c b/citadel/snprintf.c index 693a2592e..ad04a02e2 100644 --- a/citadel/snprintf.c +++ b/citadel/snprintf.c @@ -1,11 +1,9 @@ -/* - * modified from Sten Gunterberg's BUGTRAQ post of 22 Jul 1997 - * --nathan bryant - */ - /* * Replacements for snprintf() and vsnprintf() * + * modified from Sten Gunterberg's BUGTRAQ post of 22 Jul 1997 + * --nathan bryant + * * Use it only if you have the "spare" cycles needed to effectively * do every snprintf operation twice! Why is that? Because everything * is first vfprintf()'d to /dev/null to determine the number of bytes. @@ -46,19 +44,6 @@ needed (const char *fmt, va_list argp) return vfprintf(sink, fmt, argp); } -int -snprintf (char *buf, size_t max, const char *fmt, ...) -{ - va_list argp; - int bytes; - - va_start(argp, fmt); - bytes = vsnprintf(buf, max, fmt, argp); - va_end(argp); - - return bytes; -} - int vsnprintf (char *buf, size_t max, const char *fmt, va_list argp) { @@ -79,3 +64,16 @@ vsnprintf (char *buf, size_t max, const char *fmt, va_list argp) free(p); return size; } + +int +snprintf (char *buf, size_t max, const char *fmt, ...) +{ + va_list argp; + int bytes; + + va_start(argp, fmt); + bytes = vsnprintf(buf, max, fmt, argp); + va_end(argp); + + return bytes; +}