mirror of https://github.com/madler/zlib
parent
3e4aa45834
commit
84c6716a48
17
deflate.c
17
deflate.c
|
@ -1333,7 +1333,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
||||||
|
|
||||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
||||||
|
"need lookahead");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Assert(cur_match < s->strstart, "no future");
|
Assert(cur_match < s->strstart, "no future");
|
||||||
|
@ -1357,7 +1358,7 @@ local uInt longest_match(s, cur_match)
|
||||||
/* It is not necessary to compare scan[2] and match[2] since they are
|
/* It is not necessary to compare scan[2] and match[2] since they are
|
||||||
* always equal when the other bytes match, given that the hash keys
|
* always equal when the other bytes match, given that the hash keys
|
||||||
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
||||||
* strstart+3, +5, ... up to strstart+257. We check for insufficient
|
* strstart + 3, + 5, up to strstart + 257. We check for insufficient
|
||||||
* lookahead only every 4th comparison; the 128th check will be made
|
* lookahead only every 4th comparison; the 128th check will be made
|
||||||
* at strstart + 257. If MAX_MATCH-2 is not a multiple of 8, it is
|
* at strstart + 257. If MAX_MATCH-2 is not a multiple of 8, it is
|
||||||
* necessary to put more guard bytes at the end of the window, or
|
* necessary to put more guard bytes at the end of the window, or
|
||||||
|
@ -1374,7 +1375,8 @@ local uInt longest_match(s, cur_match)
|
||||||
/* The funny "do {}" generates better code on most compilers */
|
/* The funny "do {}" generates better code on most compilers */
|
||||||
|
|
||||||
/* Here, scan <= window + strstart + 257 */
|
/* Here, scan <= window + strstart + 257 */
|
||||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
||||||
|
"wild scan");
|
||||||
if (*scan == *match) scan++;
|
if (*scan == *match) scan++;
|
||||||
|
|
||||||
len = (MAX_MATCH - 1) - (int)(strend - scan);
|
len = (MAX_MATCH - 1) - (int)(strend - scan);
|
||||||
|
@ -1406,7 +1408,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*++scan == *++match && *++scan == *++match &&
|
*++scan == *++match && *++scan == *++match &&
|
||||||
scan < strend);
|
scan < strend);
|
||||||
|
|
||||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
||||||
|
"wild scan");
|
||||||
|
|
||||||
len = MAX_MATCH - (int)(strend - scan);
|
len = MAX_MATCH - (int)(strend - scan);
|
||||||
scan = strend - MAX_MATCH;
|
scan = strend - MAX_MATCH;
|
||||||
|
@ -1451,7 +1454,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
||||||
|
|
||||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
||||||
|
"need lookahead");
|
||||||
|
|
||||||
Assert(cur_match < s->strstart, "no future");
|
Assert(cur_match < s->strstart, "no future");
|
||||||
|
|
||||||
|
@ -2155,7 +2159,8 @@ local block_state deflate_rle(s, flush)
|
||||||
if (s->match_length > s->lookahead)
|
if (s->match_length > s->lookahead)
|
||||||
s->match_length = s->lookahead;
|
s->match_length = s->lookahead;
|
||||||
}
|
}
|
||||||
Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (uInt)(s->window_size - 1),
|
||||||
|
"wild scan");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
||||||
|
|
8
trees.c
8
trees.c
|
@ -807,8 +807,8 @@ local int build_bl_tree(s)
|
||||||
|
|
||||||
/* Build the bit length tree: */
|
/* Build the bit length tree: */
|
||||||
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
||||||
/* opt_len now includes the length of the tree representations, except
|
/* opt_len now includes the length of the tree representations, except the
|
||||||
* the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
* lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Determine the number of bit length codes to send. The pkzip format
|
/* Determine the number of bit length codes to send. The pkzip format
|
||||||
|
@ -1014,7 +1014,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
int ZLIB_INTERNAL _tr_tally(s, dist, lc)
|
int ZLIB_INTERNAL _tr_tally(s, dist, lc)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
unsigned dist; /* distance of matched string */
|
unsigned dist; /* distance of matched string */
|
||||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */
|
||||||
{
|
{
|
||||||
s->sym_buf[s->sym_next++] = (uch)dist;
|
s->sym_buf[s->sym_next++] = (uch)dist;
|
||||||
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
|
||||||
|
@ -1060,7 +1060,7 @@ local void compress_block(s, ltree, dtree)
|
||||||
} else {
|
} else {
|
||||||
/* Here, lc is the match length - MIN_MATCH */
|
/* Here, lc is the match length - MIN_MATCH */
|
||||||
code = _length_code[lc];
|
code = _length_code[lc];
|
||||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
send_code(s, code + LITERALS + 1, ltree); /* send length code */
|
||||||
extra = extra_lbits[code];
|
extra = extra_lbits[code];
|
||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
lc -= base_length[code];
|
lc -= base_length[code];
|
||||||
|
|
Loading…
Reference in New Issue