From: Phil Vachon Date: Mon, 30 Jan 2017 14:28:25 +0000 (+0100) Subject: Add block_open state for deflate_quick X-Git-Tag: 1.9.9-b1~696 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=302d456950effd6ecb8724da1aca36be66827e91;p=thirdparty%2Fzlib-ng.git Add block_open state for deflate_quick By storing whether or not a block has been opened (or terminated), the static trees used for the block and the end block markers can be emitted appropriately. --- diff --git a/arch/x86/deflate_quick.c b/arch/x86/deflate_quick.c index c7e805d70..422c3250e 100644 --- a/arch/x86/deflate_quick.c +++ b/arch/x86/deflate_quick.c @@ -177,6 +177,7 @@ static void static_emit_end_block(deflate_state *const s, int last) { s->block_start = s->strstart; flush_pending(s->strm); + s->block_open = 0; } static inline Pos quick_insert_string(deflate_state *const s, const Pos str) { @@ -203,8 +204,9 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { IPos hash_head; unsigned dist, match_len; - if (s->strm->total_out == 2) { + if (s->block_open == 0) { static_emit_tree(s, flush); + s->block_open = 1; } do { diff --git a/deflate.h b/deflate.h index 75e14b1b7..c8381cbfb 100644 --- a/deflate.h +++ b/deflate.h @@ -281,6 +281,12 @@ typedef struct internal_state { * longest match routines access bytes past the input. This is then * updated to the new high water mark. */ + int block_open; + /* Whether or not a block is currently open for the QUICK deflation scheme. + * This is set to 1 if there is an active block, or 0 if the block was just + * closed. + */ + } deflate_state; typedef enum {