]> mj.ucw.cz Git - libucw.git/blobdiff - lib/ff-printf.c
Use big_alloc().
[libucw.git] / lib / ff-printf.c
index fe9c964283d2a0e6e1eff67b90fd3420e89014b7..769f830e1cd5423e7db5e80831bc090ba67e98b0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     UCW Library -- Printf on Fastbuf Streams
  *
 /*
  *     UCW Library -- Printf on Fastbuf Streams
  *
- *     (c) 2002 Martin Mares <mj@ucw.cz>
+ *     (c) 2002--2005 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -17,11 +17,14 @@ vbprintf(struct fastbuf *b, char *msg, va_list args)
 {
   byte *buf;
   int len, r;
 {
   byte *buf;
   int len, r;
+  va_list args2;
 
   len = bdirect_write_prepare(b, &buf);
   if (len >= 16)
     {
 
   len = bdirect_write_prepare(b, &buf);
   if (len >= 16)
     {
-      r = vsnprintf(buf, len, msg, args);
+      va_copy(args2, args);
+      r = vsnprintf(buf, len, msg, args2);
+      va_end(args2);
       if (r < 0)
        len = 256;
       else if (r < len)
       if (r < 0)
        len = 256;
       else if (r < len)
@@ -38,7 +41,9 @@ vbprintf(struct fastbuf *b, char *msg, va_list args)
   while (1)
     {
       buf = alloca(len);
   while (1)
     {
       buf = alloca(len);
-      r = vsnprintf(buf, len, msg, args);
+      va_copy(args2, args);
+      r = vsnprintf(buf, len, msg, args2);
+      va_end(args2);
       if (r < 0)
        len += len;
       else if (r < len)
       if (r < 0)
        len += len;
       else if (r < len)