mirror of
https://github.com/fluencelabs/musl
synced 2025-06-24 20:21:59 +00:00
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.
This commit is contained in:
@ -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 vdprintf(int fd, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int r;
|
|
||||||
unsigned char buf[BUFSIZ];
|
|
||||||
FILE f = {
|
FILE f = {
|
||||||
.fd = fd, .lbf = EOF, .write = wrap_write,
|
.fd = fd, .lbf = EOF, .write = wrap_write,
|
||||||
.buf = buf+UNGET, .buf_size = sizeof buf - UNGET,
|
.buf = (void *)fmt, .buf_size = 0,
|
||||||
.lock = -1
|
.lock = -1
|
||||||
};
|
};
|
||||||
r = vfprintf(&f, fmt, ap);
|
return vfprintf(&f, fmt, ap);
|
||||||
return fflush(&f) ? EOF : r;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user