]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Update high water mark in deflate_stored.
authorMark Adler <madler@alumni.caltech.edu>
Sun, 15 Jan 2017 16:15:55 +0000 (08:15 -0800)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 13 Feb 2017 09:08:53 +0000 (10:08 +0100)
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 ...

deflate.c

index 4032fb291d541fdaa634923d15febc4cc03d49b6..456e5e805f5fd2516b845985e3166d6d15a2582b 100644 (file)
--- 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