[Toybox] [PATCH] count.c: Human readable -h option and MAYFORK
Oliver Webb
aquahobbyist at proton.me
Sun Oct 15 21:23:12 PDT 2023
Hey, I was looking through the command list and discovered a "count" command.
After learning what it did it reminded me of a tool called pv (Pipe viewer)
which does the exact same thing with more info that I was planning to make
a rudimentary implementation of in toybox.
I want to add a -v[erbose] option that displays info like average input/second
(size/seconds since start) and time since start, Since we are already doing stuff
with 'millitime()' to speed up the command, It wouldn't be that much work. But it seems
a bit overkill and feature-creep-y for a command that is so simple so I didn't include
one in this patch. I did however add a '-h' Human readable count option.
The only memory that gets accumulated is 'buf' that can be freed easily at the end of the command.
I did some memory leak checking on count (calling the main function 10,000 times and watching
in htop if any memory in being accumulated). Then some more precise checking with valgrind.
count now accumulates as much memory as any other (memory-leakless) command in toybox
(80 bytes lost, probably infrastructure stuff but I dunno). And there doesn't seem to be a reason not
to MAYFORK it.
Oliver Webb <aquahobbyist at proton.me>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-count.c-Add-MAYFORK-and-remove-memory-leak-Add-h-Hum.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20231016/de9abf6b/attachment.bin>
More information about the Toybox
mailing list