The last commit created a memory leak because 'buf' is static. Fix that,
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 7 Nov 2004 23:44:38 +0000 (23:44 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 7 Nov 2004 23:44:38 +0000 (23:44 +0000)
commit5845dd65e0039ae771a82338edb41579e55e8f69
tree12b2175d52cf2e96bfac5855b5f618d016f66e78
parent7ba6f9789c178057d51eb5674192b06f2e5ec338
The last commit created a memory leak because 'buf' is static.  Fix that,
but also make the chosen block size more consistent by basing on the larger
of STDOUT vs rfd rather then just basing it on STDOUT, and change the
constant 1024 to BUFSIZ.

It is unclear whether we should impose a minimum buffer size or a mod
(e.g. x % st_blksize == 0) requirement as well.  There are currently no cases
where this matters as anyone in their right mind will use 'dd' instead of
'cat' on special block devices.  But at least in regards to /proc/*/map
imposing a minimum based on fstat(rfd, ...) makes sense, though to really
be correct we should also 'fix' procfs to report a block size sufficient to
hold the map data in that case.

Reported-by: Jason Smethers <jason@smethers.net>
bin/cat/cat.c