aboutsummaryrefslogtreecommitdiffstats
path: root/c/sha3sum.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-07-24 13:48:35 +0200
committerMattias Andrée <maandree@operamail.com>2013-07-24 13:48:35 +0200
commit820b457917a4440752ac03ca0ea1c1bcfa4e6e38 (patch)
tree897ba8897b3b30f931369cdd6641e0c6ead04550 /c/sha3sum.c
parentin case st_blksize is not properly set (diff)
downloadsha3sum-820b457917a4440752ac03ca0ea1c1bcfa4e6e38.tar.gz
sha3sum-820b457917a4440752ac03ca0ea1c1bcfa4e6e38.tar.bz2
sha3sum-820b457917a4440752ac03ca0ea1c1bcfa4e6e38.tar.xz
use st_blksize in c implementation
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'c/sha3sum.c')
-rw-r--r--c/sha3sum.c7
1 files changed, 5 insertions, 2 deletions
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 <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
-#include <stdlib.h>
+#include <sys/stat.h>
#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 (;;)
{