提交 f1ebdd6a 编写于 作者: M Mark Adler

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.
上级 bafcad90
......@@ -155,6 +155,9 @@ local const config configuration_table[10] = {
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
#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
* 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
* 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) {
ERR_RETURN(strm, Z_BUF_ERROR);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册