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)
Thu, Sep 10, 5:00 PM
Unknown Object (File)
Thu, Sep 10, 1:33 AM
Unknown Object (File)
Tue, Sep 8, 5:35 AM
Unknown Object (File)
Tue, Sep 8, 2:27 AM
Unknown Object (File)
Mon, Sep 7, 1:49 AM
Unknown Object (File)
Sun, Sep 6, 10:42 AM
Unknown Object (File)
Sun, Sep 6, 12:51 AM
Unknown Object (File)
Sat, Sep 5, 6:22 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.