[PATCH v2 05/14] stdio-common: Introduce buffers for implementing printf

Adhemerval Zanella adhemerval.zanella@linaro.org
Thu Jun 2 18:48:52 GMT 2022



On 23/05/2022 11:07, Florian Weimer via Libc-alpha wrote:
> +
> +void
> +__printf_buffer_flush_to_file (struct __printf_buffer_to_file *buf)
> +{
> +  /* The bytes in the buffer are always consumed.  */
> +  buf->base.written += buf->base.write_ptr - buf->base.write_base;
> +
> +  if (buf->base.write_end == array_end (buf->stage))
> +    {
> +      /* If the stage buffer is used, make a copy into the file.  The
> +         stage buffer is always consumed fully, even if just partially
> +         written, to ensure that the file stream has all the data.  */
> +      size_t count = buf->base.write_ptr - buf->stage;
> +      if ((size_t) _IO_sputn (buf->fp, buf->stage, count) != count)
> +            {
> +              __printf_buffer_mark_failed (&buf->base);
> +              return;
> +            }

Indentation seems off here.


More information about the Libc-alpha mailing list