Page MenuHomeFreeBSD

stdio: *memstream: slightly streamline growth function
AcceptedPublic

Authored by kevans on May 29 2026, 11:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 4, 12:28 AM
Unknown Object (File)
Sat, Jun 27, 11:29 PM
Unknown Object (File)
Sat, Jun 27, 11:28 PM
Unknown Object (File)
Wed, Jun 24, 3:49 PM
Unknown Object (File)
Sun, Jun 21, 9:16 PM
Unknown Object (File)
Sun, Jun 21, 9:16 PM
Unknown Object (File)
Sat, Jun 20, 10:39 PM
Unknown Object (File)
Wed, Jun 17, 12:12 AM
Subscribers

Details

Reviewers
jhb
des
Group Reviewers
Klara
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.