summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2017-01-16 09:49:35 -0800
committerMark Adler <madler@alumni.caltech.edu>2017-02-15 22:38:55 -0800
commitf9694097dd69354b03cb8af959094c7f260db0a1 (patch)
tree3077a3e9e3eb1de0bb1fb65b439f1701c9ea91d6 /deflate.c
parent5ff989033e8b839b80ce716a1452acf7664e2ff4 (diff)
downloadzlib-f9694097dd69354b03cb8af959094c7f260db0a1.tar.gz
zlib-f9694097dd69354b03cb8af959094c7f260db0a1.tar.bz2
zlib-f9694097dd69354b03cb8af959094c7f260db0a1.zip
Permit a deflateParams() parameter change as soon as possible.
This commit allows a parameter change even if the input data has not all been compressed and copied to the application output buffer, so long as all of the input data has been compressed to the internal pending output buffer. This also allows an immediate deflateParams change so long as there have been no deflate calls since initialization or reset.
Diffstat (limited to '')
-rw-r--r--deflate.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/deflate.c b/deflate.c
index b63311a..20bda4f 100644
--- a/deflate.c
+++ b/deflate.c
@@ -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) {