changeset 334:83c461db9df7

Check in crc_init needed by cksum. (Oops.)
author Rob Landley <rob@landley.net>
date Sat, 03 Jan 2009 18:15:18 -0600
parents d5d8f9a6e649
children 556c10abdff6
files lib/bunzip.c lib/lib.c lib/lib.h
diffstat 3 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib/bunzip.c	Sat Dec 27 05:37:47 2008 -0600
+++ b/lib/bunzip.c	Sat Jan 03 18:15:18 2009 -0600
@@ -592,7 +592,7 @@
 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 @@
 		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++)
--- a/lib/lib.c	Sat Dec 27 05:37:47 2008 -0600
+++ b/lib/lib.c	Sat Jan 03 18:15:18 2009 -0600
@@ -718,3 +718,18 @@
 	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;
+	}
+}
--- a/lib/lib.h	Sat Dec 27 05:37:47 2008 -0600
+++ b/lib/lib.h	Sat Jan 03 18:15:18 2009 -0600
@@ -96,6 +96,7 @@
 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 {