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)
Dec 20 2023, 7:13 AM
Unknown Object (File)
Oct 9 2023, 11:24 PM
Unknown Object (File)
Jul 6 2023, 11:40 PM
Unknown Object (File)
Jun 26 2023, 10:06 PM
Unknown Object (File)
May 11 2023, 11:04 PM
Unknown Object (File)
May 11 2023, 10:58 PM
Unknown Object (File)
May 11 2023, 10:57 PM
Unknown Object (File)
May 5 2023, 4:22 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 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.