diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-12-28 23:57:14 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-12-28 23:57:14 -0800 |
commit | f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9 (patch) | |
tree | e6d279c19147fba9c2fa4118b9c9f2fe316e725f | |
parent | bafcad90289cb72993e32a5fe8f31c4e60629f9e (diff) | |
download | zlib-f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9.tar.gz zlib-f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9.tar.bz2 zlib-f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9.zip |
Permit stronger flushes after Z_BLOCK flushes.
The incorporation of the Z_BLOCK flush did not update the rejection
of lower ranked flushes immediately after higher ranked flushes with
no more input data. This prevented an empty Z_SYNC_FLUSH right after
a Z_BLOCK flush, which would be desired to bring the deflate stream
to a byte boundary conditionally on whether or not it was already at
a byte boundary. This patch re-ranks Z_BLOCK above Z_NO_FLUSH but
below Z_PARTIAL_FLUSH, allowing stronger empty flushes to follow a
Z_BLOCK flush.
-rw-r--r-- | deflate.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -155,6 +155,9 @@ local const config configuration_table[10] = { | |||
155 | struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | 155 | struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ | ||
159 | #define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) | ||
160 | |||
158 | /* =========================================================================== | 161 | /* =========================================================================== |
159 | * Update a hash value with the given input byte | 162 | * Update a hash value with the given input byte |
160 | * IN assertion: all calls to to UPDATE_HASH are made with consecutive | 163 | * IN assertion: all calls to to UPDATE_HASH are made with consecutive |
@@ -858,7 +861,7 @@ int ZEXPORT deflate (strm, flush) | |||
858 | * flushes. For repeated and useless calls with Z_FINISH, we keep | 861 | * flushes. For repeated and useless calls with Z_FINISH, we keep |
859 | * returning Z_STREAM_END instead of Z_BUF_ERROR. | 862 | * returning Z_STREAM_END instead of Z_BUF_ERROR. |
860 | */ | 863 | */ |
861 | } else if (strm->avail_in == 0 && flush <= old_flush && | 864 | } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && |
862 | flush != Z_FINISH) { | 865 | flush != Z_FINISH) { |
863 | ERR_RETURN(strm, Z_BUF_ERROR); | 866 | ERR_RETURN(strm, Z_BUF_ERROR); |
864 | } | 867 | } |