From: Mark Adler Date: Sun, 15 Jan 2017 16:15:55 +0000 (-0800) Subject: Update high water mark in deflate_stored. X-Git-Tag: 1.9.9-b1~700 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae98290ecd90fab08f950de37319bfeac45c816b;p=thirdparty%2Fzlib-ng.git Update high water mark in deflate_stored. This avoids unnecessary filling of bytes in the sliding window buffer when switching from level zero to a non-zero level. This also provides a consistent indication of deflate having taken input for a later commit ... --- diff --git a/deflate.c b/deflate.c index 4032fb291..456e5e805 100644 --- a/deflate.c +++ b/deflate.c @@ -1430,6 +1430,8 @@ static block_state deflate_stored(deflate_state *s, int flush) { s->block_start = s->strstart; s->insert += MIN(used, s->w_size - s->insert); } + if (s->high_water < s->strstart) + s->high_water = s->strstart; /* If the last block was written to next_out, then done. */ if (last) @@ -1457,6 +1459,8 @@ static block_state deflate_stored(deflate_state *s, int flush) { read_buf(s->strm, s->window + s->strstart, have); s->strstart += have; } + if (s->high_water < s->strstart) + s->high_water = s->strstart; /* There was not enough avail_out to write a complete worthy or flushed * stored block to next_out. Write a stored block to pending instead, if we