From: Hans Kristian Rosbach Date: Fri, 1 Nov 2019 10:39:46 +0000 (+0100) Subject: Clean up usage of bflush make more similar for each deflate strategy. X-Git-Tag: 1.9.9-b1~335 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30ad51882695ea464264edd4798cb5f384727173;p=thirdparty%2Fzlib-ng.git Clean up usage of bflush make more similar for each deflate strategy. --- diff --git a/deflate.c b/deflate.c index 2309a80fe..edc9d7123 100644 --- a/deflate.c +++ b/deflate.c @@ -1552,7 +1552,7 @@ static block_state deflate_stored(deflate_state *s, int flush) { * deflate switches away from Z_RLE.) */ static block_state deflate_rle(deflate_state *s, int flush) { - int bflush; /* set if current block must be flushed */ + int bflush = 0; /* set if current block must be flushed */ unsigned int prev; /* byte at distance one to match */ unsigned char *scan, *strend; /* scan goes up to strend for length of run */ @@ -1624,7 +1624,7 @@ static block_state deflate_rle(deflate_state *s, int flush) { * (It will be regenerated if this run of deflate switches away from Huffman.) */ static block_state deflate_huff(deflate_state *s, int flush) { - int bflush; /* set if current block must be flushed */ + int bflush = 0; /* set if current block must be flushed */ for (;;) { /* Make sure that we have a literal to write. */ diff --git a/deflate_fast.c b/deflate_fast.c index cbd5bde46..af1401169 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -19,7 +19,7 @@ */ ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ + int bflush = 0; /* set if current block must be flushed */ for (;;) { /* Make sure that we always have enough lookahead, except diff --git a/deflate_medium.c b/deflate_medium.c index 052a060cf..ee988cc3e 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -21,25 +21,25 @@ struct match { }; static int emit_match(deflate_state *s, struct match match) { - int flush = 0; + int bflush = 0; /* matches that are not long enough we need to emit as literals */ if (match.match_length < MIN_MATCH) { while (match.match_length) { - flush += zng_tr_tally_lit(s, s->window[match.strstart]); + bflush += zng_tr_tally_lit(s, s->window[match.strstart]); s->lookahead--; match.strstart++; match.match_length--; } - return flush; + return bflush; } check_match(s, match.strstart, match.match_start, match.match_length); - flush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); + bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH); s->lookahead -= match.match_length; - return flush; + return bflush; } static void insert_match(deflate_state *s, struct match match) { @@ -196,7 +196,7 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) { for (;;) { IPos hash_head = 0; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ + int bflush = 0; /* set if current block must be flushed */ /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes diff --git a/deflate_slow.c b/deflate_slow.c index 11dedfb29..43931f227 100644 --- a/deflate_slow.c +++ b/deflate_slow.c @@ -26,7 +26,7 @@ */ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ + int bflush = 0; /* set if current block must be flushed */ /* Process the input block. */ for (;;) { @@ -122,7 +122,8 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { } #endif /*NOT_TWEAK_COMPILER*/ - if (bflush) FLUSH_BLOCK(s, 0); + if (bflush) + FLUSH_BLOCK(s, 0); } else if (s->match_available) { /* If there was no match at the previous position, output a @@ -131,9 +132,8 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { */ Tracevv((stderr, "%c", s->window[s->strstart-1])); bflush = zng_tr_tally_lit(s, s->window[s->strstart-1]); - if (bflush) { + if (bflush) FLUSH_BLOCK_ONLY(s, 0); - } s->strstart++; s->lookahead--; if (s->strm->avail_out == 0)