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)
Sun, Jan 19, 3:35 PM
Unknown Object (File)
Sat, Jan 18, 9:52 PM
Unknown Object (File)
Sat, Jan 18, 9:28 PM
Unknown Object (File)
Dec 25 2024, 6:34 AM
Unknown Object (File)
Nov 19 2024, 6:41 AM
Unknown Object (File)
Nov 19 2024, 6:35 AM
Unknown Object (File)
Nov 1 2024, 4:59 AM
Unknown Object (File)
Oct 8 2024, 6:29 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.