X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Finflate.c;h=6db6e98d1637b58764d3356a52ecff7216dfe3ed;hb=c5c6b216cd905dfdab60444d44628387377b6f30;hp=6a9cac881978b813fe2230d0c75e7c565a405b7d;hpb=daddc0d38b3571bed170afa273a49a0eba090c1e;p=linux-2.6.git diff --git a/lib/inflate.c b/lib/inflate.c index 6a9cac881..6db6e98d1 100644 --- a/lib/inflate.c +++ b/lib/inflate.c @@ -118,6 +118,10 @@ static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #"; #include "gzip.h" #define STATIC #endif /* !STATIC */ + +#ifndef INIT +#define INIT +#endif #define slide window @@ -139,15 +143,15 @@ struct huft { /* Function prototypes */ -STATIC int huft_build OF((unsigned *, unsigned, unsigned, +STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, const ush *, const ush *, struct huft **, int *)); -STATIC int huft_free OF((struct huft *)); -STATIC int inflate_codes OF((struct huft *, struct huft *, int, int)); -STATIC int inflate_stored OF((void)); -STATIC int inflate_fixed OF((void)); -STATIC int inflate_dynamic OF((void)); -STATIC int inflate_block OF((int *)); -STATIC int inflate OF((void)); +STATIC int INIT huft_free OF((struct huft *)); +STATIC int INIT inflate_codes OF((struct huft *, struct huft *, int, int)); +STATIC int INIT inflate_stored OF((void)); +STATIC int INIT inflate_fixed OF((void)); +STATIC int INIT inflate_dynamic OF((void)); +STATIC int INIT inflate_block OF((int *)); +STATIC int INIT inflate OF((void)); /* The inflate algorithm uses a sliding 32 K byte window on the uncompressed @@ -272,7 +276,7 @@ STATIC const int dbits = 6; /* bits in base distance lookup table */ STATIC unsigned hufts; /* track memory usage */ -STATIC int huft_build( +STATIC int INIT huft_build( unsigned *b, /* code lengths in bits (all assumed <= BMAX) */ unsigned n, /* number of codes (assumed <= N_MAX) */ unsigned s, /* number of simple-valued codes (0..s-1) */ @@ -322,7 +326,7 @@ DEBG("huft1 "); { *t = (struct huft *)NULL; *m = 0; - return 0; + return 2; } DEBG("huft2 "); @@ -370,6 +374,7 @@ DEBG("huft5 "); if ((j = *p++) != 0) v[x[j]++] = i; } while (++i < n); + n = x[g]; /* set n to length of v */ DEBG("h6 "); @@ -406,12 +411,13 @@ DEBG1("1 "); DEBG1("2 "); f -= a + 1; /* deduct codes from patterns left */ xp = c + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } + if (j < z) + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + f -= *xp; /* else deduct codes from patterns */ + } } DEBG1("3 "); z = 1 << j; /* table entries for j-bit table */ @@ -491,7 +497,7 @@ DEBG("huft7 "); -STATIC int huft_free( +STATIC int INIT huft_free( struct huft *t /* table to free */ ) /* Free the malloc'ed tables built by huft_build(), which makes a linked @@ -513,7 +519,7 @@ STATIC int huft_free( } -STATIC int inflate_codes( +STATIC int INIT inflate_codes( struct huft *tl, /* literal/length decoder tables */ struct huft *td, /* distance decoder tables */ int bl, /* number of bits decoded by tl[] */ @@ -628,7 +634,7 @@ STATIC int inflate_codes( -STATIC int inflate_stored(void) +STATIC int INIT inflate_stored(void) /* "decompress" an inflated type 0 (stored) block. */ { unsigned n; /* number of bytes in block */ @@ -689,7 +695,7 @@ DEBG("