# HG changeset patch # User Olaf Wintermann # Date 1376488462 -7200 # Node ID b6dcc9d112ebe8fb4e3425ab6cd109b507388e1f # Parent b843d463ac58426249ac5ef9dec3d3d8668056e2 fixed printf functions diff -r b843d463ac58 -r b6dcc9d112eb ucx/utils.c --- a/ucx/utils.c Wed Aug 14 15:24:14 2013 +0200 +++ b/ucx/utils.c Wed Aug 14 15:54:22 2013 +0200 @@ -147,6 +147,8 @@ int ucx_vfprintf(void *stream, write_func wfc, const char *fmt, va_list ap) { char buf[UCX_PRINTF_BUFSIZE]; + va_list ap2; + va_copy(ap2, ap); int ret = vsnprintf(buf, UCX_PRINTF_BUFSIZE, fmt, ap); if (ret < 0) { return ret; @@ -164,7 +166,8 @@ return -1; } - ret = vsnprintf(newbuf, len, fmt, ap); + ret = vsnprintf(newbuf, len, fmt, ap2); + va_end(ap2); if (ret > 0) { ret = (int)wfc(newbuf, 1, ret, stream); } @@ -186,6 +189,8 @@ sstr_t s; s.ptr = NULL; s.length = 0; + va_list ap2; + va_copy(ap2, ap); char buf[UCX_PRINTF_BUFSIZE]; int ret = vsnprintf(buf, UCX_PRINTF_BUFSIZE, fmt, ap); if (ret > 0 && ret < UCX_PRINTF_BUFSIZE) { @@ -198,7 +203,8 @@ } else { int len = ret + 1; s.ptr = (char*)a->malloc(a->pool, len); - ret = vsnprintf(s.ptr, len, fmt, ap); + ret = vsnprintf(s.ptr, len, fmt, ap2); + va_end(ap2); if (ret < 0) { free(s.ptr); s.ptr = NULL; diff -r b843d463ac58 -r b6dcc9d112eb ucx/utils.h --- a/ucx/utils.h Wed Aug 14 15:24:14 2013 +0200 +++ b/ucx/utils.h Wed Aug 14 15:54:22 2013 +0200 @@ -202,7 +202,7 @@ int ucx_vfprintf(void *stream, write_func wfc, const char *fmt, va_list ap); /** - * A printf lile function which stores the result in a newly created string. + * A printf like function which stores the result in a newly created string. * * The sstr_t data is allocated with the allocators ucx_allocator_malloc * function. So it is implementation depended, whether the returned