summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2017-01-15 08:22:16 -0800
committerMark Adler <madler@alumni.caltech.edu>2017-01-15 09:29:40 -0800
commitcbbd20302c6e3fb626bee5bd8b4932524049515c (patch)
tree91a632d17b1f7596af41e10537872ed02ee87d33
parent7d9c9d410a7f8c732fdb0cac2b268659d624a6b6 (diff)
downloadzlib-cbbd20302c6e3fb626bee5bd8b4932524049515c.tar.gz
zlib-cbbd20302c6e3fb626bee5bd8b4932524049515c.tar.bz2
zlib-cbbd20302c6e3fb626bee5bd8b4932524049515c.zip
Permit immediate deflateParams changes before any deflate input.
This permits deflateParams to change the strategy and level right after deflateInit, without having to wait until a header has been written. The parameters can be changed immediately up until the first deflate call that consumes any input data.
-rw-r--r--deflate.c3
-rw-r--r--zlib.h9
2 files changed, 7 insertions, 5 deletions
diff --git a/deflate.c b/deflate.c
index 8a1a91e..f146001 100644
--- a/deflate.c
+++ b/deflate.c
@@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
586 } 586 }
587 func = configuration_table[s->level].func; 587 func = configuration_table[s->level].func;
588 588
589 if ((strategy != s->strategy || func != configuration_table[level].func)) { 589 if ((strategy != s->strategy || func != configuration_table[level].func) &&
590 s->high_water) {
590 /* Flush the last buffer: */ 591 /* Flush the last buffer: */
591 int err = deflate(strm, Z_BLOCK); 592 int err = deflate(strm, Z_BLOCK);
592 if (err == Z_STREAM_ERROR) 593 if (err == Z_STREAM_ERROR)
diff --git a/zlib.h b/zlib.h
index feabc54..a4b3baf 100644
--- a/zlib.h
+++ b/zlib.h
@@ -712,10 +712,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
712 used to switch between compression and straight copy of the input data, or 712 used to switch between compression and straight copy of the input data, or
713 to switch to a different kind of input data requiring a different strategy. 713 to switch to a different kind of input data requiring a different strategy.
714 If the compression approach (which is a function of the level) or the 714 If the compression approach (which is a function of the level) or the
715 strategy is changed, then the input available so far is compressed with the 715 strategy is changed, and if any input has been consumed in a previous
716 old level and strategy using deflate(strm, Z_BLOCK). There are three 716 deflate() call, then the input available so far is compressed with the old
717 approaches for the compression levels 0, 1..3, and 4..9 respectively. The 717 level and strategy using deflate(strm, Z_BLOCK). There are three approaches
718 new level and strategy will take effect at the next call of deflate(). 718 for the compression levels 0, 1..3, and 4..9 respectively. The new level
719 and strategy will take effect at the next call of deflate().
719 720
720 If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does 721 If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
721 not have enough output space to complete, then the parameter change will not 722 not have enough output space to complete, then the parameter change will not