src/slz.c
/* Make the table for a fast CRC.
 * Not thread-safe, must be called exactly once.
 */
Make the table for a fast CRC.
Not thread-safe, must be called exactly once.
Make the table for a fast CRC . Not thread - safe must be called exactly once .
void slz_make_crc_table(void)
{
	uint32_t c;
	int n, k;
	for (n = 0; n < 256; n++) {
		c = (uint32_t) n ^ 255;
		for (k = 0; k < 8; k++) {
			if (c & 1) {
				c = 0xedb88320 ^ (c >> 1);
			} else {
				c = c >> 1;
			}
		}
		crc32_fast[0][n] = c ^ 0xff000000;
	}
	for (n = 0; n < 256; n++) {
		crc32_fast[1][n] = 0xff000000 ^ crc32_fast[0][(0xff000000 ^ crc32_fast[0][n] ^ 0xff) & 0xff] ^ (crc32_fast[0][n] >> 8);
		crc32_fast[2][n] = 0xff000000 ^ crc32_fast[0][(0x00ff0000 ^ crc32_fast[1][n] ^ 0xff) & 0xff] ^ (crc32_fast[1][n] >> 8);
		crc32_fast[3][n] = 0xff000000 ^ crc32_fast[0][(0x0000ff00 ^ crc32_fast[2][n] ^ 0xff) & 0xff] ^ (crc32_fast[2][n] >> 8);
	}
}
void slz_make_crc_table ( void ) { uint32_t c ; int n , k ; for ( n = 0 ; n < 256 ; n ++ ) { c = ( uint32_t ) n ^ 255 ; for ( k = 0 ; k < 8 ; k ++ ) { if ( c & 1 ) { c = 0xedb88320 ^ ( c >> 1 ) ; } else { c = c >> 1 ; } } crc32_fast [ 0 ] [ n ] = c ^ 0xff000000 ; } for ( n = 0 ; n < 256 ; n ++ ) { crc32_fast [ 1 ] [ n ] = 0xff000000 ^ crc32_fast [ 0 ] [ ( 0xff000000 ^ crc32_fast [ 0 ] [ n ] ^ 0xff ) & 0xff ] ^ ( crc32_fast [ 0 ] [ n ] >> 8 ) ; crc32_fast [ 2 ] [ n ] = 0xff000000 ^ crc32_fast [ 0 ] [ ( 0x00ff0000 ^ crc32_fast [ 1 ] [ n ] ^ 0xff ) & 0xff ] ^ ( crc32_fast [ 1 ] [ n ] >> 8 ) ; crc32_fast [ 3 ] [ n ] = 0xff000000 ^ crc32_fast [ 0 ] [ ( 0x0000ff00 ^ crc32_fast [ 2 ] [ n ] ^ 0xff ) & 0xff ] ^ ( crc32_fast [ 2 ] [ n ] >> 8 ) ; } }
Make the table for a fast CRC.
Make the table for a fast CRC .
/* Note: here we *do not* have to invert the bits corresponding to the
	 * byte position, because [0] already has the 8 highest bits inverted,
	 * and these bits are shifted by 8 at the end of the operation, which
	 * results in having the next 8 bits shifted in turn. That's why we
	 * have the xor in the index used just after a computation.
	 */