[PATCH v2] libio: Ignore setbuf for open_memstream [BZ #34019]
Rocket Ma
marocketbd@gmail.com
Fri May 1 16:24:07 GMT 2026
> Wouldn't this change the behavior or setbuf (NULL, ..) and setbuf (..., 0)
> to not be _IO_UNBUFFERED?
>
> I think it does not seems to matter though, since the resulting buffer operated
> by open_memstream can only be accessible after a fflush/fclose. The
> setbuf/setvbuf would only be a way to optimize the stdio buffer flush to
> final one, which I am also not fully sure it would matter here.
>
Referencing POSIX standard[1], fflush and fclose are explicitly
mentioned when describing `bufp` and `sizep`, which may indicate that
user shall always flush the stream. But the standard does not mention
the behavior of setbuf. I'm also not sure if we should allow user to
setbuf.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/open_memstream.html
More information about the Libc-alpha
mailing list