]> git.lizzy.rs Git - zlib.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)
committerMark Adler <madler@alumni.caltech.edu>
Sun, 15 Jan 2017 17:29:27 +0000 (09:29 -0800)
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 0aa020ef506d2100f86f2819fb0672dbcbc5cfe6..8a1a91ea9841996bb57664331bda307bea69e6d3 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -1756,6 +1756,8 @@ local block_state deflate_stored(s, 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)
@@ -1783,6 +1785,8 @@ local block_state deflate_stored(s, 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