aboutsummaryrefslogtreecommitdiff
path: root/crc32.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:06:52 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:06:52 -0700
commit64b2e892035cf6ea98800c54dce0d63730d50272 (patch)
treee3b569f87e413eaef4a13469acfd4224b2a63d3a /crc32.c
parent4ca984fb447ac57120c394cf2fbba23837ed31c2 (diff)
downloadzlib-64b2e892035cf6ea98800c54dce0d63730d50272.tar.gz
zlib-64b2e892035cf6ea98800c54dce0d63730d50272.tar.bz2
zlib-64b2e892035cf6ea98800c54dce0d63730d50272.zip
zlib 0.9v0.9
Diffstat (limited to 'crc32.c')
-rw-r--r--crc32.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/crc32.c b/crc32.c
index e8d385f..d9485c2 100644
--- a/crc32.c
+++ b/crc32.c
@@ -3,12 +3,17 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: crc32.c,v 1.4 1995/04/14 14:55:12 jloup Exp $ */ 6/* $Id: crc32.c,v 1.5 1995/05/01 13:55:46 jloup Exp $ */
7 7
8#include "zlib.h" 8#include "zlib.h"
9 9
10extern uLong crc_table[]; /* crc table, defined below */ 10extern uLong crc_table[]; /* crc table, defined below */
11 11
12#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
13#define DO2(buf) DO1(buf); DO1(buf);
14#define DO4(buf) DO2(buf); DO2(buf);
15#define DO8(buf) DO4(buf); DO4(buf);
16
12/* ========================================================================= */ 17/* ========================================================================= */
13uLong crc32(crc, buf, len) 18uLong crc32(crc, buf, len)
14 uLong crc; 19 uLong crc;
@@ -17,8 +22,13 @@ uLong crc32(crc, buf, len)
17{ 22{
18 if (buf == Z_NULL) return 0L; 23 if (buf == Z_NULL) return 0L;
19 crc = crc ^ 0xffffffffL; 24 crc = crc ^ 0xffffffffL;
25 while (len >= 8)
26 {
27 DO8(buf);
28 len -= 8;
29 }
20 if (len) do { 30 if (len) do {
21 crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); 31 DO1(buf);
22 } while (--len); 32 } while (--len);
23 return crc ^ 0xffffffffL; 33 return crc ^ 0xffffffffL;
24} 34}
@@ -29,7 +39,7 @@ uLong crc32(crc, buf, len)
29 */ 39 */
30#ifdef DYNAMIC_CRC_TABLE 40#ifdef DYNAMIC_CRC_TABLE
31 41
32void make_crc_table() 42local void make_crc_table()
33{ 43{
34 uLong c; 44 uLong c;
35 int n, k; 45 int n, k;