aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-12-05 13:08:03 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-12-05 13:08:03 +0000
commitef03dbcd4db03fcab7b6f48a7038226d202775ca (patch)
treed8631e9e4c384462c0268179b23ed40bbdccd70d /archival/libunarchive
parentaad44fb37a3f68dc82e5387c1bf13e3b29daab24 (diff)
downloadbusybox-ef03dbcd4db03fcab7b6f48a7038226d202775ca.tar.gz
Simplify CRC table generation
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/decompress_unzip.c16
-rw-r--r--archival/libunarchive/unzip.c16
2 files changed, 10 insertions, 22 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 69cc8198b..c28ca836c 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -123,22 +123,16 @@ static void abort_gzip(void)
static void make_crc_table(void)
{
- unsigned long table_entry; /* crc shift register */
- unsigned long poly = 0; /* polynomial exclusive-or pattern */
- int i; /* counter for all possible eight bit values */
- int k; /* byte being shifted into crc apparatus */
-
- /* terms of polynomial defining this crc (except x^32): */
- static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
+ const unsigned long poly = 0xedb88320; /* polynomial exclusive-or pattern */
+ unsigned short i; /* counter for all possible eight bit values */
crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));
- /* Make exclusive-or pattern from polynomial (0xedb88320) */
- for (i = 0; i < sizeof(p)/sizeof(int); i++)
- poly |= 1L << (31 - p[i]);
-
/* Compute and print table of CRC's, five per line */
for (i = 0; i < 256; i++) {
+ unsigned long table_entry; /* crc shift register */
+ char k; /* byte being shifted into crc apparatus */
+
table_entry = i;
/* The idea to initialize the register with the byte instead of
* zero was stolen from Haruhiko Okumura's ar002
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c
index 69cc8198b..c28ca836c 100644
--- a/archival/libunarchive/unzip.c
+++ b/archival/libunarchive/unzip.c
@@ -123,22 +123,16 @@ static void abort_gzip(void)
static void make_crc_table(void)
{
- unsigned long table_entry; /* crc shift register */
- unsigned long poly = 0; /* polynomial exclusive-or pattern */
- int i; /* counter for all possible eight bit values */
- int k; /* byte being shifted into crc apparatus */
-
- /* terms of polynomial defining this crc (except x^32): */
- static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
+ const unsigned long poly = 0xedb88320; /* polynomial exclusive-or pattern */
+ unsigned short i; /* counter for all possible eight bit values */
crc_table = (unsigned long *) malloc(256 * sizeof(unsigned long));
- /* Make exclusive-or pattern from polynomial (0xedb88320) */
- for (i = 0; i < sizeof(p)/sizeof(int); i++)
- poly |= 1L << (31 - p[i]);
-
/* Compute and print table of CRC's, five per line */
for (i = 0; i < 256; i++) {
+ unsigned long table_entry; /* crc shift register */
+ char k; /* byte being shifted into crc apparatus */
+
table_entry = i;
/* The idea to initialize the register with the byte instead of
* zero was stolen from Haruhiko Okumura's ar002