From bc403863f2038d1ac9bf610e50b1c7641099eebb Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 3 Aug 2005 15:03:42 +0000 Subject: [PATCH] moor boogz git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@456 9efc2488-bf62-4759-914b-345cdb29e865 --- src/utils/utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index 60d665a..830861a 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -105,10 +105,18 @@ int buffer_fadd(growing_buffer* gb, const char* format, ... ) { if(!gb || !format) return 0; + int len = 0; va_list args; + va_list a_copy; + + char* f_copy = strdup(format); + + va_copy(a_copy,args); + + va_start(a_copy, f_copy); + len = vsnprintf(NULL, 0, f_copy, a_copy); + va_end(a_copy); - va_start(args, format); - int len = vsnprintf(NULL, 0, format, args); len += 1; char buf[len]; @@ -118,6 +126,8 @@ int buffer_fadd(growing_buffer* gb, const char* format, ... ) { vsnprintf(buf, len - 1, format, args); va_end(args); + free(f_copy); + return buffer_add(gb, buf); } -- 2.11.0