about summary refs log tree commit diff
path: root/src/stdio/vdprintf.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-04 16:30:39 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-04 16:30:39 -0400
commit98c5583ad5d633166e28034c0a3544ad48b532b6 (patch)
tree1f759837200e20d23613c8a70e383a42424f1271 /src/stdio/vdprintf.c
parentbd57e2b43a5b56c00a82adbde0e33e5820c81164 (diff)
downloadmusl-98c5583ad5d633166e28034c0a3544ad48b532b6.tar.gz
musl-98c5583ad5d633166e28034c0a3544ad48b532b6.tar.xz
musl-98c5583ad5d633166e28034c0a3544ad48b532b6.zip
simplify vdprintf implementation greatly based on recent vfprintf changes
since vfprintf will provide a temporary buffer in the case where the
target FILE has a zero buffer size, don't bother setting up a real
buffer for vdprintf. this also allows us to skip the call to fflush
since we know everything will be written out before vfprintf returns.
Diffstat (limited to 'src/stdio/vdprintf.c')
-rw-r--r--src/stdio/vdprintf.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/stdio/vdprintf.c b/src/stdio/vdprintf.c
index faf9536a..b41a3c74 100644
--- a/src/stdio/vdprintf.c
+++ b/src/stdio/vdprintf.c
@@ -7,13 +7,10 @@ static size_t wrap_write(FILE *f, const unsigned char *buf, size_t len)
 
 int vdprintf(int fd, const char *fmt, va_list ap)
 {
-	int r;
-	unsigned char buf[BUFSIZ];
 	FILE f = {
 		.fd = fd, .lbf = EOF, .write = wrap_write,
-		.buf = buf+UNGET, .buf_size = sizeof buf - UNGET,
+		.buf = (void *)fmt, .buf_size = 0,
 		.lock = -1
 	};
-	r = vfprintf(&f, fmt, ap);
-	return fflush(&f) ? EOF : r;
+	return vfprintf(&f, fmt, ap);
 }