aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
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;
+ }
+}