--- trunk/mkinitrd-magellan/busybox/archival/libunarchive/decompress_uncompress.c 2009/04/24 18:32:46 815 +++ trunk/mkinitrd-magellan/busybox/archival/libunarchive/decompress_uncompress.c 2009/04/24 18:33:46 816 @@ -1,13 +1,10 @@ /* vi: set sw=4 ts=4: */ -#include "libbb.h" - /* uncompress for busybox -- (c) 2002 Robert Griebl * * based on the original compress42.c source * (see disclaimer below) */ - /* (N)compress42.c - File compression ala IEEE Computer, Mar 1992. * * Authors: @@ -26,9 +23,10 @@ * [... History snipped ...] * */ -#include -#include -#include + +#include "libbb.h" +#include "unarchive.h" + /* Default input buffer size */ #define IBUFSIZ 2048 @@ -37,72 +35,67 @@ #define OBUFSIZ 2048 /* Defines for third byte of header */ -#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */ -#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */ -#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */ - /* Masks 0x20 and 0x40 are free. */ - /* I think 0x20 should mean that there is */ - /* a fourth header byte (for expansion). */ -#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */ - /* compression rate is dropping flush tables */ - /* the next two codes should not be changed lightly, as they must not */ - /* lie within the contiguous general code space. */ -#define FIRST 257 /* first free entry */ -#define CLEAR 256 /* table clear output code */ +#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */ + /* Masks 0x20 and 0x40 are free. */ + /* I think 0x20 should mean that there is */ + /* a fourth header byte (for expansion). */ +#define BLOCK_MODE 0x80 /* Block compression if table is full and */ + /* compression rate is dropping flush tables */ + /* the next two codes should not be changed lightly, as they must not */ + /* lie within the contiguous general code space. */ +#define FIRST 257 /* first free entry */ +#define CLEAR 256 /* table clear output code */ -#define INIT_BITS 9 /* initial number of bits/code */ +#define INIT_BITS 9 /* initial number of bits/code */ /* machine variants which require cc -Dmachine: pdp11, z8000, DOS */ -#define FAST - -#define HBITS 17 /* 50% occupancy */ -#define HSIZE (1< BITS) { bb_error_msg("compressed with %d bits, can only handle " - "%d bits", maxbits, BITS); - return -1; + BITS_STR" bits", maxbits); + goto err; } n_bits = INIT_BITS; @@ -143,7 +138,7 @@ free_ent = ((block_mode) ? FIRST : 256); /* As above, initialize the first 256 entries in the table. */ - clear_tab_prefixof(); + /*clear_tab_prefixof(); - done by xzalloc */ for (code = 255; code >= 0; --code) { tab_suffixof(code) = (unsigned char) code; @@ -235,7 +230,7 @@ insize, posbits, p[-1], p[0], p[1], p[2], p[3], (posbits & 07)); bb_error_msg("uncompress: corrupt input"); - return -1; + goto err; } *--stackp = (unsigned char) finchar; @@ -243,7 +238,7 @@ } /* Generate output characters in reverse order */ - while ((long int) code >= (long int) 256) { + while ((long) code >= (long) 256) { *--stackp = tab_suffixof(code); code = tab_prefixof(code); } @@ -302,7 +297,11 @@ USE_DESKTOP(total_written += outpos;) } - RELEASE_CONFIG_BUFFER(inbuf); - RELEASE_CONFIG_BUFFER(outbuf); - return USE_DESKTOP(total_written) + 0; + retval = USE_DESKTOP(total_written) + 0; + err: + free(inbuf); + free(outbuf); + free(htab); + free(codetab); + return retval; }