aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2009-01-03 18:15:18 -0600
committerRob Landley <rob@landley.net>2009-01-03 18:15:18 -0600
commit7e849c5b99e539f5af5262d8ade6b9791463c796 (patch)
treef3cc5f6166eae1e099b07e7ad3006577698497f5 /lib/lib.c
parent433c030b1e1921e0253f6b9896a827aac5728cdc (diff)
downloadtoybox-7e849c5b99e539f5af5262d8ade6b9791463c796.tar.gz
Check in crc_init needed by cksum. (Oops.)
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 8f742894..f94d6fdf 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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;
+ }
+}