diff options
-rw-r--r-- | deflate.c | 15 | ||||
-rw-r--r-- | deflate.h | 1 | ||||
-rw-r--r-- | trees.c | 9 |
3 files changed, 19 insertions, 6 deletions
@@ -638,19 +638,22 @@ local void putShortMSB (s, b) | |||
638 | local void flush_pending(strm) | 638 | local void flush_pending(strm) |
639 | z_streamp strm; | 639 | z_streamp strm; |
640 | { | 640 | { |
641 | unsigned len = strm->state->pending; | 641 | unsigned len; |
642 | deflate_state *s = strm->state; | ||
642 | 643 | ||
644 | _tr_flush_bits(s); | ||
645 | len = s->pending; | ||
643 | if (len > strm->avail_out) len = strm->avail_out; | 646 | if (len > strm->avail_out) len = strm->avail_out; |
644 | if (len == 0) return; | 647 | if (len == 0) return; |
645 | 648 | ||
646 | zmemcpy(strm->next_out, strm->state->pending_out, len); | 649 | zmemcpy(strm->next_out, s->pending_out, len); |
647 | strm->next_out += len; | 650 | strm->next_out += len; |
648 | strm->state->pending_out += len; | 651 | s->pending_out += len; |
649 | strm->total_out += len; | 652 | strm->total_out += len; |
650 | strm->avail_out -= len; | 653 | strm->avail_out -= len; |
651 | strm->state->pending -= len; | 654 | s->pending -= len; |
652 | if (strm->state->pending == 0) { | 655 | if (s->pending == 0) { |
653 | strm->state->pending_out = strm->state->pending_buf; | 656 | s->pending_out = s->pending_buf; |
654 | } | 657 | } |
655 | } | 658 | } |
656 | 659 | ||
@@ -296,6 +296,7 @@ void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); | |||
296 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); | 296 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); |
297 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, | 297 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, |
298 | ulg stored_len, int last)); | 298 | ulg stored_len, int last)); |
299 | void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); | ||
299 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); | 300 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); |
300 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | 301 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, |
301 | ulg stored_len, int last)); | 302 | ulg stored_len, int last)); |
@@ -877,6 +877,15 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
877 | } | 877 | } |
878 | 878 | ||
879 | /* =========================================================================== | 879 | /* =========================================================================== |
880 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) | ||
881 | */ | ||
882 | void ZLIB_INTERNAL _tr_flush_bits(s) | ||
883 | deflate_state *s; | ||
884 | { | ||
885 | bi_flush(s); | ||
886 | } | ||
887 | |||
888 | /* =========================================================================== | ||
880 | * Send one empty static block to give enough lookahead for inflate. | 889 | * Send one empty static block to give enough lookahead for inflate. |
881 | * This takes 10 bits, of which 7 may remain in the bit buffer. | 890 | * This takes 10 bits, of which 7 may remain in the bit buffer. |
882 | */ | 891 | */ |