--- src/sys/kern/inflate.c 2006/12/23 00:35:03 1.6 +++ src/sys/kern/inflate.c 2006/12/23 23:47:54 1.7 @@ -412,17 +412,19 @@ static const int dbits = 6; /* bits in b oversubscribed set of lengths), and three if not enough memory. The code with value 256 is special, and the tables are constructed so that no bits beyond that code are fetched when that code is - decoded. */ + decoded. + + Parameters: + b: code lengths in bits (all assumed <= BMAX) + n: number of codes (assumed <= N_MAX) + s: number of simple-valued codes (0..s-1) + d: list of base values for non-simple codes + e: list of extra bits for non-simple codes + t: result: starting table + m: maximum lookup bits, returns actual */ static int -huft_build(glbl, b, n, s, d, e, t, m) - struct inflate *glbl; - 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) */ - const ush *d; /* list of base values for non-simple codes */ - const ush *e; /* list of extra bits for non-simple codes */ - struct huft **t; /* result: starting table */ - int *m; /* maximum lookup bits, returns actual */ +huft_build(struct inflate *glbl, unsigned *b, unsigned n, unsigned s, + const ush *d, const ush *e, struct huft **t, int *m) { unsigned a; /* counter for codes of length k */ unsigned c[BMAX + 1]; /* bit length count table */ @@ -616,10 +618,12 @@ huft_build(glbl, b, n, s, d, e, t, m) return y != 0 && g != 1; } +/* + * Parameters: + * t: table to free + */ static int -huft_free(glbl, t) - struct inflate *glbl; - struct huft *t; /* table to free */ +huft_free(struct inflate *glbl, struct huft *t) /* Free the malloc'ed tables built by huft_build(), which makes a linked list of the tables it made, with the links in a dummy first entry of each table. */ @@ -637,12 +641,13 @@ huft_free(glbl, t) } /* inflate (decompress) the codes in a deflated (compressed) block. - Return an error code or zero if it all goes ok. */ + Return an error code or zero if it all goes ok. + + tl, td - literal/length and distance decoder tables + bl, bd - number of bits decoded by tl[] and td[] */ static int -inflate_codes(glbl, tl, td, bl, bd) - struct inflate *glbl; - struct huft *tl, *td;/* literal/length and distance decoder tables */ - int bl, bd; /* number of bits decoded by tl[] and td[] */ +inflate_codes(struct inflate *glbl, struct huft *tl, struct huft *td, + int bl, int bd) { unsigned e; /* table entry flag/number of extra bits */ unsigned n, d; /* length and index for copy */ @@ -735,8 +740,7 @@ inflate_codes(glbl, tl, td, bl, bd) /* "decompress" an inflated type 0 (stored) block. */ static int -inflate_stored(glbl) - struct inflate *glbl; +inflate_stored(struct inflate *glbl) { unsigned n; /* number of bytes in block */ unsigned w; /* current window position */ @@ -782,8 +786,7 @@ inflate_stored(glbl) either replace this with a custom decoder, or at least precompute the Huffman tables. */ static int -inflate_fixed(glbl) - struct inflate *glbl; +inflate_fixed(struct inflate *glbl) { /* if first time, set up tables for fixed blocks */ if (glbl->gz_fixed_tl == (struct huft *) NULL) { @@ -824,8 +827,7 @@ inflate_fixed(glbl) /* decompress an inflated type 2 (dynamic Huffman codes) block. */ static int -inflate_dynamic(glbl) - struct inflate *glbl; +inflate_dynamic(struct inflate *glbl) { int i; /* temporary variables */ unsigned j; @@ -968,11 +970,11 @@ inflate_dynamic(glbl) return 0; } -/* decompress an inflated block */ +/* decompress an inflated block + + e - last block flag */ static int -inflate_block(glbl, e) - struct inflate *glbl; - int *e; /* last block flag */ +inflate_block(struct inflate *glbl, int *e) { unsigned t; /* block type */ ulg b; /* bit buffer */ @@ -1009,8 +1011,7 @@ inflate_block(glbl, e) /* decompress an inflated entry */ static int -xinflate(glbl) - struct inflate *glbl; +xinflate(struct inflate *glbl) { int e; /* last block flag */ int r; /* result code */ @@ -1042,8 +1043,7 @@ xinflate(glbl) /* Nobody uses this - why not? */ int -inflate(glbl) - struct inflate *glbl; +inflate(struct inflate *glbl) { int i; #ifdef _KERNEL