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.
This commit is contained in:
parent
bafcad9028
commit
f1ebdd6a9c
@ -155,6 +155,9 @@ local const config configuration_table[10] = {
|
|||||||
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
|
||||||
|
#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Update a hash value with the given input byte
|
* Update a hash value with the given input byte
|
||||||
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
|
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
|
||||||
@ -858,7 +861,7 @@ int ZEXPORT deflate (strm, flush)
|
|||||||
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
||||||
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
||||||
*/
|
*/
|
||||||
} else if (strm->avail_in == 0 && flush <= old_flush &&
|
} else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
|
||||||
flush != Z_FINISH) {
|
flush != Z_FINISH) {
|
||||||
ERR_RETURN(strm, Z_BUF_ERROR);
|
ERR_RETURN(strm, Z_BUF_ERROR);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user