diff options
| -rw-r--r-- | deflate.c | 6 | ||||
| -rw-r--r-- | zlib.h | 11 |
2 files changed, 9 insertions, 8 deletions
| @@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm) | |||
| 494 | s->wrap == 2 ? crc32(0L, Z_NULL, 0) : | 494 | s->wrap == 2 ? crc32(0L, Z_NULL, 0) : |
| 495 | #endif | 495 | #endif |
| 496 | adler32(0L, Z_NULL, 0); | 496 | adler32(0L, Z_NULL, 0); |
| 497 | s->last_flush = Z_NO_FLUSH; | 497 | s->last_flush = -2; |
| 498 | 498 | ||
| 499 | _tr_init(s); | 499 | _tr_init(s); |
| 500 | 500 | ||
| @@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
| 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 | s->last_flush != -2) { |
| 591 | /* Flush the last buffer: */ | 591 | /* Flush the last buffer: */ |
| 592 | int err = deflate(strm, Z_BLOCK); | 592 | int err = deflate(strm, Z_BLOCK); |
| 593 | if (err == Z_STREAM_ERROR) | 593 | if (err == Z_STREAM_ERROR) |
| 594 | return err; | 594 | return err; |
| 595 | if (strm->avail_out == 0) | 595 | if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) |
| 596 | return Z_BUF_ERROR; | 596 | return Z_BUF_ERROR; |
| 597 | } | 597 | } |
| 598 | if (s->level != level) { | 598 | if (s->level != level) { |
| @@ -712,11 +712,12 @@ 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, and if any input has been consumed in a previous | 715 | strategy is changed, and if there have been any deflate() calls since the |
| 716 | deflate() call, then the input available so far is compressed with the old | 716 | state was initialized or reset, then the input available so far is |
| 717 | level and strategy using deflate(strm, Z_BLOCK). There are three approaches | 717 | compressed with the old level and strategy using deflate(strm, Z_BLOCK). |
| 718 | for the compression levels 0, 1..3, and 4..9 respectively. The new level | 718 | There are three approaches for the compression levels 0, 1..3, and 4..9 |
| 719 | and strategy will take effect at the next call of deflate(). | 719 | respectively. The new level and strategy will take effect at the next call |
| 720 | of deflate(). | ||
| 720 | 721 | ||
| 721 | If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does | 722 | If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does |
| 722 | not have enough output space to complete, then the parameter change will not | 723 | not have enough output space to complete, then the parameter change will not |
