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)
Nov 24 2025, 1:37 PM
Unknown Object (File)
Nov 16 2025, 6:03 PM
Unknown Object (File)
Nov 13 2025, 5:12 AM
Unknown Object (File)
Nov 7 2025, 12:14 PM
Unknown Object (File)
Oct 29 2025, 11:54 AM
Unknown Object (File)
Oct 29 2025, 11:53 AM
Unknown Object (File)
Oct 29 2025, 11:51 AM
Unknown Object (File)
Oct 18 2025, 9:47 PM
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 Not Applicable
Unit
Tests Not Applicable

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.