Page MenuHomeFreeBSD

wc: Make the read buffer static.
ClosedPublic

Authored by des on Feb 15 2023, 2:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 1, 4:59 AM
Unknown Object (File)
Oct 8 2024, 6:29 PM
Unknown Object (File)
Oct 4 2024, 12:15 PM
Unknown Object (File)
Oct 4 2024, 12:12 PM
Unknown Object (File)
Oct 2 2024, 6:47 AM
Unknown Object (File)
Oct 2 2024, 4:25 AM
Unknown Object (File)
Sep 27 2024, 7:12 AM
Unknown Object (File)
Sep 25 2024, 9:07 AM
Subscribers

Details

Summary

The read buffer in cnt() is 64 kB, which is a bit excessive for a stack variable. MAXBSIZE has grown since this code was originally written, and it might grow again in the future. Since the program is single-threaded and cnt() does not recurse, we can safely make the buffer static.

While there, constify p since it is only used to read.

Sponsored by: Klara, Inc.

Diff Detail

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

Event Timeline

des requested review of this revision.Feb 15 2023, 2:37 PM

I find the static variable a bit icky (could just malloc the buffer), but agree with the justification for it being OK.

This revision is now accepted and ready to land.Feb 15 2023, 11:51 PM
This revision was automatically updated to reflect the committed changes.