unsigned long bb; /* bit buffer */
unsigned int bk; /* bits in bit buffer */
+
+ uint32_t crc_32_tab[256];
+ uint32_t crc;
};
#define malloc(a) xmalloc_bytes(a)
* The window is equal to the output buffer therefore only need to
* compute the crc.
*/
- unsigned long c = crc;
+ uint32_t c = ~s->crc;
unsigned int n;
unsigned char *in, ch;
for ( n = 0; n < s->wp; n++ )
{
ch = *in++;
- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
+ c = s->crc_32_tab[(c ^ ch) & 0xff] ^ (c >> 8);
}
- crc = c;
+ s->crc = ~c;
s->bytes_out += s->wp;
s->wp = 0;
s->inptr = 0;
s->bytes_out = 0;
- makecrc();
+ makecrc(s);
if ( gunzip(s) < 0 )
{
*
**********************************************************************/
-static ulg __initdata crc_32_tab[256];
-static ulg __initdata crc; /* initialized in makecrc() so it'll reside in bss */
-#define CRC_VALUE (crc ^ 0xffffffffUL)
-
/*
* Code to compute the CRC-32 table. Borrowed from
* gzip-1.0.3/makecrc.c.
*/
-static void __init makecrc(void)
+static void __init makecrc(struct gunzip_state *s)
{
/* Not copyrighted 1990 Mark Adler */
for (i = 0; i < sizeof(p)/sizeof(int); i++)
e |= 1L << (31 - p[i]);
- crc_32_tab[0] = 0;
+ s->crc_32_tab[0] = 0;
for (i = 1; i < 256; i++)
{
if (k & 1)
c ^= e;
}
- crc_32_tab[i] = c;
+ s->crc_32_tab[i] = c;
}
- /* this is initialized here so this code could reside in ROM */
- crc = (ulg)0xffffffffUL; /* shift register contents */
+ s->crc = 0;
}
/* gzip flag byte */
orig_len |= (ulg) NEXTBYTE(s) << 24;
/* Validate decompression */
- if (orig_crc != CRC_VALUE) {
+ if ( orig_crc != s->crc )
+ {
error("crc error");
return -1;
}