diff options
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -718,3 +718,18 @@ void replace_tempfile(int fdin, int fdout, char **tempname) free(temp); *tempname = NULL; } + +// Create a 256 entry CRC32 lookup table. + +void crc_init(unsigned int *crc_table) +{ + unsigned int i; + + // Init the CRC32 table (big endian) + for (i=0; i<256; i++) { + unsigned int j, c = i<<24; + for (j=8; j; j--) + c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1); + crc_table[i] = c; + } +} |