From 64b2e892035cf6ea98800c54dce0d63730d50272 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:06:52 -0700 Subject: zlib 0.9 --- crc32.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'crc32.c') diff --git a/crc32.c b/crc32.c index e8d385f..d9485c2 100644 --- a/crc32.c +++ b/crc32.c @@ -3,12 +3,17 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* $Id: crc32.c,v 1.4 1995/04/14 14:55:12 jloup Exp $ */ +/* $Id: crc32.c,v 1.5 1995/05/01 13:55:46 jloup Exp $ */ #include "zlib.h" extern uLong crc_table[]; /* crc table, defined below */ +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + /* ========================================================================= */ uLong crc32(crc, buf, len) uLong crc; @@ -17,8 +22,13 @@ uLong crc32(crc, buf, len) { if (buf == Z_NULL) return 0L; crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } if (len) do { - crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); + DO1(buf); } while (--len); return crc ^ 0xffffffffL; } @@ -29,7 +39,7 @@ uLong crc32(crc, buf, len) */ #ifdef DYNAMIC_CRC_TABLE -void make_crc_table() +local void make_crc_table() { uLong c; int n, k; -- cgit v1.2.3-55-g6feb