diff src/lzfu.c @ 73:3cb02cb1e6cd stable-0-6-10

Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them). More changes for Fedora packaging (#434727) Fixes for const correctness.
author Carl Byington <carl@five-ten-sg.com>
date Thu, 29 May 2008 18:51:02 -0700
parents f66078abed38
children 535075b4d261
line wrap: on
line diff
--- a/src/lzfu.c	Fri May 16 09:06:17 2008 -0700
+++ b/src/lzfu.c	Thu May 29 18:51:02 2008 -0700
@@ -40,7 +40,7 @@
 } lzfuheader;
 
 
-unsigned char* lzfu_decompress (unsigned char* rtfcomp, uint32_t compsize, size_t *size) {
+char* lzfu_decompress (char* rtfcomp, uint32_t compsize, size_t *size) {
 	// the dictionary buffer
 	unsigned char dict[4096];
 	// the dictionary pointer
@@ -52,7 +52,7 @@
 	// temp value for determining the bits in the flag
 	unsigned char flag_mask;
 	uint32_t i;
-	unsigned char *out_buf;
+	char *out_buf;
 	uint32_t out_ptr  = 0;
 	uint32_t out_size;
 	uint32_t in_ptr;
@@ -71,11 +71,11 @@
 	//printf("CRC       : %#x\n", lzfuhdr.dwCRC);
 	//printf("\n");
 	out_size = lzfuhdr.cbRawSize + 3;	// two braces and a null terminator
-	out_buf  = (unsigned char*)xmalloc(out_size);
+	out_buf  = (char*)xmalloc(out_size);
 	in_ptr	 = sizeof(lzfuhdr);
 	in_size  = (lzfuhdr.cbSize < compsize) ? lzfuhdr.cbSize : compsize;
 	while (in_ptr < in_size) {
-		flags = rtfcomp[in_ptr++];
+		flags = (unsigned char)(rtfcomp[in_ptr++]);
 		flag_mask = 1;
 		while (flag_mask) {
 			if (flag_mask & flags) {
@@ -99,7 +99,7 @@
 						c1 = dict[(offset+i)%4096];
 						dict[dict_length]=c1;
 						dict_length = (dict_length+1) % 4096;
-						if (out_ptr < out_size) out_buf[out_ptr++] = c1;
+						if (out_ptr < out_size) out_buf[out_ptr++] = (char)c1;
 					}
 				}
 			} else {
@@ -109,7 +109,7 @@
 					char c1 = rtfcomp[in_ptr++];
 					dict[dict_length] = c1;
 					dict_length = (dict_length+1)%4096;
-					if (out_ptr < out_size) out_buf[out_ptr++] = c1;
+					if (out_ptr < out_size) out_buf[out_ptr++] = (char)c1;
 				}
 			}
 			flag_mask <<= 1;