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 | |
parent | 433c030b1e1921e0253f6b9896a827aac5728cdc (diff) | |
download | toybox-7e849c5b99e539f5af5262d8ade6b9791463c796.tar.gz |
Check in crc_init needed by cksum. (Oops.)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bunzip.c | 10 | ||||
-rw-r--r-- | lib/lib.c | 15 | ||||
-rw-r--r-- | lib/lib.h | 1 |
3 files changed, 18 insertions, 8 deletions
diff --git a/lib/bunzip.c b/lib/bunzip.c index ae842891..18984af4 100644 --- a/lib/bunzip.c +++ b/lib/bunzip.c @@ -592,7 +592,7 @@ dataus_interruptus: int start_bunzip(struct bunzip_data **bdp, int src_fd, char *inbuf, int len) { struct bunzip_data *bd; - unsigned int i, j, c; + unsigned int i; // Figure out how much data to allocate. i = sizeof(struct bunzip_data); @@ -609,13 +609,7 @@ int start_bunzip(struct bunzip_data **bdp, int src_fd, char *inbuf, int len) bd->in_fd = src_fd; } - // Init the CRC32 table (big endian) - for (i=0; i<256; i++) { - c = i<<24; - for (j=8; j; j--) - c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1); - bd->crc32Table[i] = c; - } + crc_init(bd->crc32Table); // Ensure that file starts with "BZh". for (i=0;i<3;i++) @@ -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; + } +} @@ -96,6 +96,7 @@ void xsendfile(int in, int out); int copy_tempfile(int fdin, char *name, char **tempname); void delete_tempfile(int fdin, int fdout, char **tempname); void replace_tempfile(int fdin, int fdout, char **tempname); +void crc_init(unsigned int *crc_table); // getmountlist.c struct mtab_list { |