diff options
author | Rob Landley <rob@landley.net> | 2009-01-03 18:15:18 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2009-01-03 18:15:18 -0600 |
commit | 7e849c5b99e539f5af5262d8ade6b9791463c796 (patch) | |
tree | f3cc5f6166eae1e099b07e7ad3006577698497f5 /lib/lib.c | |
parent | 433c030b1e1921e0253f6b9896a827aac5728cdc (diff) | |
download | toybox-7e849c5b99e539f5af5262d8ade6b9791463c796.tar.gz |
Check in crc_init needed by cksum. (Oops.)
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; + } +} |