Page MenuHomeFreeBSD

stdio: *memstream: slightly streamline growth function
ClosedPublic

Authored by kevans on May 29 2026, 11:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 20, 3:58 AM
Unknown Object (File)
Tue, Aug 18, 8:13 AM
Unknown Object (File)
Mon, Aug 17, 1:48 PM
Unknown Object (File)
Sun, Aug 16, 7:04 PM
Unknown Object (File)
Sat, Aug 15, 6:27 AM
Unknown Object (File)
Fri, Aug 14, 10:40 AM
Unknown Object (File)
Fri, Aug 14, 8:23 AM
Unknown Object (File)
Thu, Aug 13, 3:30 AM
Subscribers

Details

Summary

Inverting the condition after realloc*() is a minor cleanup, but makes
the success path a little cleaner to ease a future change.

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73564
Build 70447: arc lint + arc unit

Event Timeline

des added a subscriber: des.

afaict the only difference between these files is wchar_t vs char. I wonder if we should merge them.

This revision is now accepted and ready to land.Jun 3 2026, 12:55 PM
In D57353#1315249, @des wrote:

afaict the only difference between these files is wchar_t vs char. I wonder if we should merge them.

There's some other small differences like having to use mbrlen, but I don't think that's a huge obstacle and it'd be good to merge them -- it just requires a little more thought into the abstractions we need. I think converting the non-wide version to reallocarray and introducing a MEMCHAR_TYPE (or whatever) gets you most of the way there- we can probably take most of the wmemstream implementation and assume that the compiler will just optimize away a lot of the differences when it's dealing with a fixed-width byte input to the stream.