@@ -16,8 +16,6 @@ struct match {
1616 uInt orgstart ;
1717};
1818
19- #define MAX_DIST2 ((1 << MAX_WBITS) - MIN_LOOKAHEAD)
20-
2119static int tr_tally_dist (deflate_state * s , int distance , int length )
2220{
2321 return _tr_tally (s , distance , length );
@@ -113,6 +111,7 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match
113111 unsigned char * match , * orig ;
114112 int changed = 0 ;
115113 struct match c ,n ;
114+ uInt maxDist ;
116115 /* step zero: sanity checks */
117116
118117 if (current -> match_length <= 1 )
@@ -142,7 +141,8 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match
142141 n = * next ;
143142
144143 /* step one: try to move the "next" match to the left as much as possible */
145- limit = next -> strstart > MAX_DIST2 ? next -> strstart - MAX_DIST2 : 0 ;
144+ maxDist = MAX_DIST (s );
145+ limit = next -> strstart > maxDist ? next -> strstart - maxDist : 0 ;
146146
147147 match = s -> window + n .match_start - 1 ;
148148 orig = s -> window + n .strstart - 1 ;
@@ -230,7 +230,7 @@ block_state deflate_medium(deflate_state *s, int flush)
230230 * At this point we have always match_length < MIN_MATCH
231231 */
232232
233- if (hash_head != 0 && s -> strstart - hash_head <= MAX_DIST2 ) {
233+ if (hash_head != 0 && s -> strstart - hash_head <= MAX_DIST ( s ) ) {
234234 /* To simplify the code, we prevent matches with the string
235235 * of window index 0 (in particular we have to avoid a match
236236 * of the string with itself at the start of the input file).
@@ -265,7 +265,7 @@ block_state deflate_medium(deflate_state *s, int flush)
265265 /* Find the longest match, discarding those <= prev_length.
266266 * At this point we have always match_length < MIN_MATCH
267267 */
268- if (hash_head != 0 && s -> strstart - hash_head <= MAX_DIST2 ) {
268+ if (hash_head != 0 && s -> strstart - hash_head <= MAX_DIST ( s ) ) {
269269 /* To simplify the code, we prevent matches with the string
270270 * of window index 0 (in particular we have to avoid a match
271271 * of the string with itself at the start of the input file).
0 commit comments