From e8a0788b249cbac5bf5b2aa2d81bb8f6b29a7a4b Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 10 Jun 2007 15:08:44 +0000 Subject: moved biggest stack buffers to malloc space, or made their size configurable (8k of shell line edit buffer is an overkill) # make ARCH=i386 bloatcheck function old new delta read_line_input 3933 3967 +34 ifaddrlist 348 345 -3 do_loadfont 208 191 -17 edit_file 840 819 -21 .rodata 129112 129080 -32 uncompress 1305 1268 -37 loadfont_main 566 495 -71 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/6 up/down: 34/-181) Total: -147 bytes --- archival/libunarchive/decompress_uncompress.c | 98 +++++++++++++-------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'archival') diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c index ba73f11..8c3c65d 100644 --- a/archival/libunarchive/decompress_uncompress.c +++ b/archival/libunarchive/decompress_uncompress.c @@ -7,7 +7,6 @@ * (see disclaimer below) */ - /* (N)compress42.c - File compression ala IEEE Computer, Mar 1992. * * Authors: @@ -34,53 +33,48 @@ #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 INIT_BITS 9 /* initial number of bits/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 */ -/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */ -#define FAST +#define INIT_BITS 9 /* initial number of bits/code */ -#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; @@ -140,7 +136,7 @@ uncompress(int fd_in, int fd_out) 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; @@ -232,7 +228,7 @@ uncompress(int fd_in, int fd_out) 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; @@ -299,7 +295,11 @@ uncompress(int fd_in, int fd_out) 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; } -- cgit v1.1