========================================================================= */
| 772 | |
| 773 | /* ========================================================================= */ |
| 774 | int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { |
| 775 | deflate_state *s; |
| 776 | compress_func func; |
| 777 | |
| 778 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 779 | s = strm->state; |
| 780 | |
| 781 | #ifdef FASTEST |
| 782 | if (level != 0) level = 1; |
| 783 | #else |
| 784 | if (level == Z_DEFAULT_COMPRESSION) level = 6; |
| 785 | #endif |
| 786 | if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { |
| 787 | return Z_STREAM_ERROR; |
| 788 | } |
| 789 | func = configuration_table[s->level].func; |
| 790 | |
| 791 | if ((strategy != s->strategy || func != configuration_table[level].func) && |
| 792 | s->last_flush != -2) { |
| 793 | /* Flush the last buffer: */ |
| 794 | int err = deflate(strm, Z_BLOCK); |
| 795 | if (err == Z_STREAM_ERROR) |
| 796 | return err; |
| 797 | if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) |
| 798 | return Z_BUF_ERROR; |
| 799 | } |
| 800 | if (s->level != level) { |
| 801 | if (s->level == 0 && s->matches != 0) { |
| 802 | if (s->matches == 1) |
| 803 | slide_hash(s); |
| 804 | else |
| 805 | CLEAR_HASH(s); |
| 806 | s->matches = 0; |
| 807 | } |
| 808 | s->level = level; |
| 809 | s->max_lazy_match = configuration_table[level].max_lazy; |
| 810 | s->good_match = configuration_table[level].good_length; |
| 811 | s->nice_match = configuration_table[level].nice_length; |
| 812 | s->max_chain_length = configuration_table[level].max_chain; |
| 813 | } |
| 814 | s->strategy = strategy; |
| 815 | return Z_OK; |
| 816 | } |
| 817 | |
| 818 | /* ========================================================================= */ |
| 819 | int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, |
no test coverage detected