[PATCH v6 02/11] stdio-common: Introduce buffers for implementing printf
Florian Weimer
fweimer@redhat.com
Fri Dec 16 20:59:39 GMT 2022
* Noah Goldstein:
>> +/* Switch to the file buffer if possible. If the file has write_ptr
>> + == write_end, use the stage buffer instead. */
>> +void
>> +__printf_buffer_to_file_switch (struct __printf_buffer_to_file *buf)
>> +{
>> + if (buf->fp->_IO_write_ptr < buf->fp->_IO_write_end)
>> + {
>
> Think maybe this should have a minimum bound so we don't end up
> in a situation where the strnlen / memcpy loop is only doing 1/2
> bytes at a time.
> Probably something like 32/64 would make sense.
I think this would only matter with setvbuf and a small buffer. We can
use half of the staging buffer size (PRINTF_BUFFER_SIZE_TO_FILE_STAGE),
that would be your 64 number.
Thanks,
Florian
More information about the Libc-alpha
mailing list