From 820b457917a4440752ac03ca0ea1c1bcfa4e6e38 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 24 Jul 2013 13:48:35 +0200 Subject: use st_blksize in c implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- c/sha3sum.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'c') diff --git a/c/sha3sum.c b/c/sha3sum.c index 4467a72..edfaddf 100644 --- a/c/sha3sum.c +++ b/c/sha3sum.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ #include -#include +#include #include "sha3.h" @@ -566,6 +566,7 @@ int main(int argc, char** argv) char* filename; char* fn; long f, fail, _; + struct stat attr; char* out = binary ? null : (char*)malloc(bn * 2); @@ -592,7 +593,9 @@ int main(int argc, char** argv) if ((filename != null) || (stdin == null)) { initialise(r, c, o); - blksize = 4096; /** XXX os.stat(os.path.realpath(fn)).st_size; **/ + blksize = stat(*(argv + f), &attr) ? 0 : attr.st_blksize; + if (blksize <= 0) + blksize = 4096; chunk = (char*)malloc(blksize); for (;;) { -- cgit v1.2.3-70-g09d2