2 * UCW Library -- Printf on Fastbuf Streams
4 * (c) 2002--2013 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include <ucw/fastbuf.h>
18 vbprintf(struct fastbuf *b, const char *msg, va_list args)
25 remains = bdirect_write_prepare(b, &buf);
26 len = vsnprintf(buf, remains, msg, args2);
31 bdirect_write_commit(b, buf + len);
35 int bufsize = len + 1;
38 buf = alloca(bufsize);
41 buf = xmalloc(bufsize);
45 vsnprintf(buf, bufsize, msg, args);
54 bprintf(struct fastbuf *b, const char *msg, ...)
60 res = vbprintf(b, msg, args);
69 struct fastbuf *b = bfdopen_shared(1, 65536);
70 for (int i=0; i<10000; i++)
71 bprintf(b, "13=%d str=<%s> msg=%m\n", 13, "str");