Lines Matching refs:s
73 typedef block_state (*compress_func) OF((deflate_state *s, int flush));
76 local void fill_window OF((deflate_state *s));
77 local block_state deflate_stored OF((deflate_state *s, int flush));
78 local block_state deflate_fast OF((deflate_state *s, int flush));
80 local block_state deflate_slow OF((deflate_state *s, int flush));
82 local block_state deflate_rle OF((deflate_state *s, int flush));
83 local block_state deflate_huff OF((deflate_state *s, int flush));
84 local void lm_init OF((deflate_state *s));
85 local void putShortMSB OF((deflate_state *s, uInt b));
90 uInt longest_match OF((deflate_state *s, IPos cur_match));
92 local uInt longest_match OF((deflate_state *s, IPos cur_match));
96 local void check_match OF((deflate_state *s, IPos start, IPos match,
167 #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) argument
181 #define INSERT_STRING(s, str, match_head) \ argument
182 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
183 match_head = s->head[s->ins_h], \
184 s->head[s->ins_h] = (Pos)(str))
186 #define INSERT_STRING(s, str, match_head) \ argument
187 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
188 match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
189 s->head[s->ins_h] = (Pos)(str))
196 #define CLEAR_HASH(s) \ argument
197 s->head[s->hash_size-1] = NIL; \
198 zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
223 deflate_state *s; in deflateInit2_() local
276 s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); in deflateInit2_()
277 if (s == Z_NULL) return Z_MEM_ERROR; in deflateInit2_()
278 strm->state = (struct internal_state FAR *)s; in deflateInit2_()
279 s->strm = strm; in deflateInit2_()
281 s->wrap = wrap; in deflateInit2_()
282 s->gzhead = Z_NULL; in deflateInit2_()
283 s->w_bits = windowBits; in deflateInit2_()
284 s->w_size = 1 << s->w_bits; in deflateInit2_()
285 s->w_mask = s->w_size - 1; in deflateInit2_()
287 s->hash_bits = memLevel + 7; in deflateInit2_()
288 s->hash_size = 1 << s->hash_bits; in deflateInit2_()
289 s->hash_mask = s->hash_size - 1; in deflateInit2_()
290 s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); in deflateInit2_()
292 s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); in deflateInit2_()
293 s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); in deflateInit2_()
294 s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); in deflateInit2_()
296 s->high_water = 0; /* nothing written to s->window yet */ in deflateInit2_()
298 s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ in deflateInit2_()
300 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); in deflateInit2_()
301 s->pending_buf = (uchf *) overlay; in deflateInit2_()
302 s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); in deflateInit2_()
304 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || in deflateInit2_()
305 s->pending_buf == Z_NULL) { in deflateInit2_()
306 s->status = FINISH_STATE; in deflateInit2_()
311 s->d_buf = overlay + s->lit_bufsize/sizeof(ush); in deflateInit2_()
312 s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; in deflateInit2_()
314 s->level = level; in deflateInit2_()
315 s->strategy = strategy; in deflateInit2_()
316 s->method = (Byte)method; in deflateInit2_()
327 deflate_state *s; in deflateSetDictionary() local
335 s = strm->state; in deflateSetDictionary()
336 wrap = s->wrap; in deflateSetDictionary()
337 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) in deflateSetDictionary()
343 s->wrap = 0; /* avoid computing Adler-32 in read_buf */ in deflateSetDictionary()
346 if (dictLength >= s->w_size) { in deflateSetDictionary()
348 CLEAR_HASH(s); in deflateSetDictionary()
349 s->strstart = 0; in deflateSetDictionary()
350 s->block_start = 0L; in deflateSetDictionary()
351 s->insert = 0; in deflateSetDictionary()
353 dictionary += dictLength - s->w_size; /* use the tail */ in deflateSetDictionary()
354 dictLength = s->w_size; in deflateSetDictionary()
362 fill_window(s); in deflateSetDictionary()
363 while (s->lookahead >= MIN_MATCH) { in deflateSetDictionary()
364 str = s->strstart; in deflateSetDictionary()
365 n = s->lookahead - (MIN_MATCH-1); in deflateSetDictionary()
367 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); in deflateSetDictionary()
369 s->prev[str & s->w_mask] = s->head[s->ins_h]; in deflateSetDictionary()
371 s->head[s->ins_h] = (Pos)str; in deflateSetDictionary()
374 s->strstart = str; in deflateSetDictionary()
375 s->lookahead = MIN_MATCH-1; in deflateSetDictionary()
376 fill_window(s); in deflateSetDictionary()
378 s->strstart += s->lookahead; in deflateSetDictionary()
379 s->block_start = (long)s->strstart; in deflateSetDictionary()
380 s->insert = s->lookahead; in deflateSetDictionary()
381 s->lookahead = 0; in deflateSetDictionary()
382 s->match_length = s->prev_length = MIN_MATCH-1; in deflateSetDictionary()
383 s->match_available = 0; in deflateSetDictionary()
386 s->wrap = wrap; in deflateSetDictionary()
394 deflate_state *s; in deflateResetKeep() local
405 s = (deflate_state *)strm->state; in deflateResetKeep()
406 s->pending = 0; in deflateResetKeep()
407 s->pending_out = s->pending_buf; in deflateResetKeep()
409 if (s->wrap < 0) { in deflateResetKeep()
410 s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ in deflateResetKeep()
412 s->status = s->wrap ? INIT_STATE : BUSY_STATE; in deflateResetKeep()
415 s->wrap == 2 ? crc32(0L, Z_NULL, 0) : in deflateResetKeep()
418 s->last_flush = Z_NO_FLUSH; in deflateResetKeep()
420 _tr_init(s); in deflateResetKeep()
468 deflate_state *s; local
472 s = strm->state;
473 if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
476 put = Buf_size - s->bi_valid;
479 s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
480 s->bi_valid += put;
481 _tr_flush_bits(s);
494 deflate_state *s; in deflateParams() local
499 s = strm->state; in deflateParams()
509 func = configuration_table[s->level].func; in deflateParams()
511 if ((strategy != s->strategy || func != configuration_table[level].func) && in deflateParams()
515 if (err == Z_BUF_ERROR && s->pending == 0) in deflateParams()
518 if (s->level != level) { in deflateParams()
519 s->level = level; in deflateParams()
520 s->max_lazy_match = configuration_table[level].max_lazy; in deflateParams()
521 s->good_match = configuration_table[level].good_length; in deflateParams()
522 s->nice_match = configuration_table[level].nice_length; in deflateParams()
523 s->max_chain_length = configuration_table[level].max_chain; in deflateParams()
525 s->strategy = strategy; in deflateParams()
537 deflate_state *s; in deflateTune() local
540 s = strm->state; in deflateTune()
541 s->good_match = good_length; in deflateTune()
542 s->max_lazy_match = max_lazy; in deflateTune()
543 s->nice_match = nice_length; in deflateTune()
544 s->max_chain_length = max_chain; in deflateTune()
569 deflate_state *s; in deflateBound() local
582 s = strm->state; in deflateBound()
583 switch (s->wrap) { in deflateBound()
588 wraplen = 6 + (s->strstart ? 4 : 0); in deflateBound()
592 if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ in deflateBound()
593 if (s->gzhead->extra != Z_NULL) in deflateBound()
594 wraplen += 2 + s->gzhead->extra_len; in deflateBound()
595 str = s->gzhead->name; in deflateBound()
600 str = s->gzhead->comment; in deflateBound()
605 if (s->gzhead->hcrc) in deflateBound()
614 if (s->w_bits != 15 || s->hash_bits != 8 + 7) in deflateBound()
628 deflate_state *s, in putShortMSB() argument
631 put_byte(s, (Byte)(b >> 8)); in putShortMSB()
632 put_byte(s, (Byte)(b & 0xff)); in putShortMSB()
645 deflate_state *s = strm->state; in flush_pending() local
647 _tr_flush_bits(s); in flush_pending()
648 len = s->pending; in flush_pending()
652 zmemcpy(strm->next_out, s->pending_out, len); in flush_pending()
654 s->pending_out += len; in flush_pending()
657 s->pending -= len; in flush_pending()
658 if (s->pending == 0) { in flush_pending()
659 s->pending_out = s->pending_buf; in flush_pending()
669 deflate_state *s; in deflate() local
675 s = strm->state; in deflate()
679 (s->status == FINISH_STATE && flush != Z_FINISH)) { in deflate()
684 s->strm = strm; /* just in case */ in deflate()
685 old_flush = s->last_flush; in deflate()
686 s->last_flush = flush; in deflate()
689 if (s->status == INIT_STATE) { in deflate()
691 if (s->wrap == 2) { in deflate()
693 put_byte(s, 31); in deflate()
694 put_byte(s, 139); in deflate()
695 put_byte(s, 8); in deflate()
696 if (s->gzhead == Z_NULL) { in deflate()
697 put_byte(s, 0); in deflate()
698 put_byte(s, 0); in deflate()
699 put_byte(s, 0); in deflate()
700 put_byte(s, 0); in deflate()
701 put_byte(s, 0); in deflate()
702 put_byte(s, s->level == 9 ? 2 : in deflate()
703 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? in deflate()
705 put_byte(s, OS_CODE); in deflate()
706 s->status = BUSY_STATE; in deflate()
709 put_byte(s, (s->gzhead->text ? 1 : 0) + in deflate()
710 (s->gzhead->hcrc ? 2 : 0) + in deflate()
711 (s->gzhead->extra == Z_NULL ? 0 : 4) + in deflate()
712 (s->gzhead->name == Z_NULL ? 0 : 8) + in deflate()
713 (s->gzhead->comment == Z_NULL ? 0 : 16) in deflate()
715 put_byte(s, (Byte)(s->gzhead->time & 0xff)); in deflate()
716 put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); in deflate()
717 put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); in deflate()
718 put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); in deflate()
719 put_byte(s, s->level == 9 ? 2 : in deflate()
720 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? in deflate()
722 put_byte(s, s->gzhead->os & 0xff); in deflate()
723 if (s->gzhead->extra != Z_NULL) { in deflate()
724 put_byte(s, s->gzhead->extra_len & 0xff); in deflate()
725 put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); in deflate()
727 if (s->gzhead->hcrc) in deflate()
728 strm->adler = crc32(strm->adler, s->pending_buf, in deflate()
729 s->pending); in deflate()
730 s->gzindex = 0; in deflate()
731 s->status = EXTRA_STATE; in deflate()
737 uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; in deflate()
740 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) in deflate()
742 else if (s->level < 6) in deflate()
744 else if (s->level == 6) in deflate()
749 if (s->strstart != 0) header |= PRESET_DICT; in deflate()
752 s->status = BUSY_STATE; in deflate()
753 putShortMSB(s, header); in deflate()
756 if (s->strstart != 0) { in deflate()
757 putShortMSB(s, (uInt)(strm->adler >> 16)); in deflate()
758 putShortMSB(s, (uInt)(strm->adler & 0xffff)); in deflate()
764 if (s->status == EXTRA_STATE) { in deflate()
765 if (s->gzhead->extra != Z_NULL) { in deflate()
766 uInt beg = s->pending; /* start of bytes to update crc */ in deflate()
768 while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { in deflate()
769 if (s->pending == s->pending_buf_size) { in deflate()
770 if (s->gzhead->hcrc && s->pending > beg) in deflate()
771 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
772 s->pending - beg); in deflate()
774 beg = s->pending; in deflate()
775 if (s->pending == s->pending_buf_size) in deflate()
778 put_byte(s, s->gzhead->extra[s->gzindex]); in deflate()
779 s->gzindex++; in deflate()
781 if (s->gzhead->hcrc && s->pending > beg) in deflate()
782 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
783 s->pending - beg); in deflate()
784 if (s->gzindex == s->gzhead->extra_len) { in deflate()
785 s->gzindex = 0; in deflate()
786 s->status = NAME_STATE; in deflate()
790 s->status = NAME_STATE; in deflate()
792 if (s->status == NAME_STATE) { in deflate()
793 if (s->gzhead->name != Z_NULL) { in deflate()
794 uInt beg = s->pending; /* start of bytes to update crc */ in deflate()
798 if (s->pending == s->pending_buf_size) { in deflate()
799 if (s->gzhead->hcrc && s->pending > beg) in deflate()
800 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
801 s->pending - beg); in deflate()
803 beg = s->pending; in deflate()
804 if (s->pending == s->pending_buf_size) { in deflate()
809 val = s->gzhead->name[s->gzindex++]; in deflate()
810 put_byte(s, val); in deflate()
812 if (s->gzhead->hcrc && s->pending > beg) in deflate()
813 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
814 s->pending - beg); in deflate()
816 s->gzindex = 0; in deflate()
817 s->status = COMMENT_STATE; in deflate()
821 s->status = COMMENT_STATE; in deflate()
823 if (s->status == COMMENT_STATE) { in deflate()
824 if (s->gzhead->comment != Z_NULL) { in deflate()
825 uInt beg = s->pending; /* start of bytes to update crc */ in deflate()
829 if (s->pending == s->pending_buf_size) { in deflate()
830 if (s->gzhead->hcrc && s->pending > beg) in deflate()
831 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
832 s->pending - beg); in deflate()
834 beg = s->pending; in deflate()
835 if (s->pending == s->pending_buf_size) { in deflate()
840 val = s->gzhead->comment[s->gzindex++]; in deflate()
841 put_byte(s, val); in deflate()
843 if (s->gzhead->hcrc && s->pending > beg) in deflate()
844 strm->adler = crc32(strm->adler, s->pending_buf + beg, in deflate()
845 s->pending - beg); in deflate()
847 s->status = HCRC_STATE; in deflate()
850 s->status = HCRC_STATE; in deflate()
852 if (s->status == HCRC_STATE) { in deflate()
853 if (s->gzhead->hcrc) { in deflate()
854 if (s->pending + 2 > s->pending_buf_size) in deflate()
856 if (s->pending + 2 <= s->pending_buf_size) { in deflate()
857 put_byte(s, (Byte)(strm->adler & 0xff)); in deflate()
858 put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); in deflate()
860 s->status = BUSY_STATE; in deflate()
864 s->status = BUSY_STATE; in deflate()
869 if (s->pending != 0) { in deflate()
878 s->last_flush = -1; in deflate()
892 if (s->status == FINISH_STATE && strm->avail_in != 0) { in deflate()
898 if (strm->avail_in != 0 || s->lookahead != 0 || in deflate()
899 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { in deflate()
902 bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : in deflate()
903 (s->strategy == Z_RLE ? deflate_rle(s, flush) : in deflate()
904 (*(configuration_table[s->level].func))(s, flush)); in deflate()
907 s->status = FINISH_STATE; in deflate()
911 s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ in deflate()
924 _tr_align(s); in deflate()
926 _tr_stored_block(s, (char*)0, 0L, 0); in deflate()
931 CLEAR_HASH(s); /* forget history */ in deflate()
932 if (s->lookahead == 0) { in deflate()
933 s->strstart = 0; in deflate()
934 s->block_start = 0L; in deflate()
935 s->insert = 0; in deflate()
941 s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ in deflate()
949 if (s->wrap <= 0) return Z_STREAM_END; in deflate()
953 if (s->wrap == 2) { in deflate()
954 put_byte(s, (Byte)(strm->adler & 0xff)); in deflate()
955 put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); in deflate()
956 put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); in deflate()
957 put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); in deflate()
958 put_byte(s, (Byte)(strm->total_in & 0xff)); in deflate()
959 put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); in deflate()
960 put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); in deflate()
961 put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); in deflate()
966 putShortMSB(s, (uInt)(strm->adler >> 16)); in deflate()
967 putShortMSB(s, (uInt)(strm->adler & 0xffff)); in deflate()
973 if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ in deflate()
974 return s->pending != 0 ? Z_OK : Z_STREAM_END; in deflate()
1106 deflate_state *s) in lm_init() argument
1108 s->window_size = (ulg)2L*s->w_size; in lm_init()
1110 CLEAR_HASH(s); in lm_init()
1114 s->max_lazy_match = configuration_table[s->level].max_lazy; in lm_init()
1115 s->good_match = configuration_table[s->level].good_length; in lm_init()
1116 s->nice_match = configuration_table[s->level].nice_length; in lm_init()
1117 s->max_chain_length = configuration_table[s->level].max_chain; in lm_init()
1119 s->strstart = 0; in lm_init()
1120 s->block_start = 0L; in lm_init()
1121 s->lookahead = 0; in lm_init()
1122 s->insert = 0; in lm_init()
1123 s->match_length = s->prev_length = MIN_MATCH-1; in lm_init()
1124 s->match_available = 0; in lm_init()
1125 s->ins_h = 0; in lm_init()
1148 deflate_state *s, in longest_match() argument
1151 unsigned chain_length = s->max_chain_length;/* max hash chain length */ in longest_match()
1152 register Bytef *scan = s->window + s->strstart; /* current string */ in longest_match()
1155 int best_len = s->prev_length; /* best match length so far */ in longest_match()
1156 int nice_match = s->nice_match; /* stop if match long enough */ in longest_match()
1157 IPos limit = s->strstart > (IPos)MAX_DIST(s) ? in longest_match()
1158 s->strstart - (IPos)MAX_DIST(s) : NIL; in longest_match()
1162 Posf *prev = s->prev; in longest_match()
1163 uInt wmask = s->w_mask; in longest_match()
1169 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; in longest_match()
1173 register Bytef *strend = s->window + s->strstart + MAX_MATCH; in longest_match()
1181 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); in longest_match()
1184 if (s->prev_length >= s->good_match) { in longest_match()
1190 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; in longest_match()
1192 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); in longest_match()
1195 Assert(cur_match < s->strstart, "no future"); in longest_match()
1196 match = s->window + cur_match; in longest_match()
1233 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); in longest_match()
1265 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); in longest_match()
1273 s->match_start = cur_match; in longest_match()
1286 if ((uInt)best_len <= s->lookahead) return (uInt)best_len; in longest_match()
1287 return s->lookahead; in longest_match()
1297 deflate_state *s, in longest_match() argument
1300 register Bytef *scan = s->window + s->strstart; /* current string */ in longest_match()
1303 register Bytef *strend = s->window + s->strstart + MAX_MATCH; in longest_match()
1308 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); in longest_match()
1310 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); in longest_match()
1312 Assert(cur_match < s->strstart, "no future"); in longest_match()
1314 match = s->window + cur_match; in longest_match()
1339 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); in longest_match()
1345 s->match_start = cur_match; in longest_match()
1346 return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; in longest_match()
1356 deflate_state *s, in check_match() argument
1361 if (zmemcmp(s->window + match, in check_match()
1362 s->window + start, length) != EQUAL) { in check_match()
1366 fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); in check_match()
1372 do { putc(s->window[start++], stderr); } while (--length != 0); in check_match()
1376 # define check_match(s, start, match, length) argument
1390 deflate_state *s) in fill_window() argument
1395 uInt wsize = s->w_size; in fill_window()
1397 Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); in fill_window()
1400 more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); in fill_window()
1404 if (more == 0 && s->strstart == 0 && s->lookahead == 0) { in fill_window()
1418 if (s->strstart >= wsize+MAX_DIST(s)) { in fill_window()
1420 zmemcpy(s->window, s->window+wsize, (unsigned)wsize); in fill_window()
1421 s->match_start -= wsize; in fill_window()
1422 s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ in fill_window()
1423 s->block_start -= (long) wsize; in fill_window()
1431 n = s->hash_size; in fill_window()
1432 p = &s->head[n]; in fill_window()
1440 p = &s->prev[n]; in fill_window()
1451 if (s->strm->avail_in == 0) break; in fill_window()
1466 n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); in fill_window()
1467 s->lookahead += n; in fill_window()
1470 if (s->lookahead + s->insert >= MIN_MATCH) { in fill_window()
1471 uInt str = s->strstart - s->insert; in fill_window()
1472 s->ins_h = s->window[str]; in fill_window()
1473 UPDATE_HASH(s, s->ins_h, s->window[str + 1]); in fill_window()
1477 while (s->insert) { in fill_window()
1478 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); in fill_window()
1480 s->prev[str & s->w_mask] = s->head[s->ins_h]; in fill_window()
1482 s->head[s->ins_h] = (Pos)str; in fill_window()
1484 s->insert--; in fill_window()
1485 if (s->lookahead + s->insert < MIN_MATCH) in fill_window()
1493 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); in fill_window()
1502 if (s->high_water < s->window_size) { in fill_window()
1503 ulg curr = s->strstart + (ulg)(s->lookahead); in fill_window()
1506 if (s->high_water < curr) { in fill_window()
1510 init = s->window_size - curr; in fill_window()
1513 zmemzero(s->window + curr, (unsigned)init); in fill_window()
1514 s->high_water = curr + init; in fill_window()
1516 else if (s->high_water < (ulg)curr + WIN_INIT) { in fill_window()
1521 init = (ulg)curr + WIN_INIT - s->high_water; in fill_window()
1522 if (init > s->window_size - s->high_water) in fill_window()
1523 init = s->window_size - s->high_water; in fill_window()
1524 zmemzero(s->window + s->high_water, (unsigned)init); in fill_window()
1525 s->high_water += init; in fill_window()
1529 Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, in fill_window()
1537 #define FLUSH_BLOCK_ONLY(s, last) { \ argument
1538 _tr_flush_block(s, (s->block_start >= 0L ? \
1539 (charf *)&s->window[(unsigned)s->block_start] : \
1541 (ulg)((long)s->strstart - s->block_start), \
1543 s->block_start = s->strstart; \
1544 flush_pending(s->strm); \
1549 #define FLUSH_BLOCK(s, last) { \ argument
1550 FLUSH_BLOCK_ONLY(s, last); \
1551 if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
1564 deflate_state *s, in deflate_stored() argument
1573 if (max_block_size > s->pending_buf_size - 5) { in deflate_stored()
1574 max_block_size = s->pending_buf_size - 5; in deflate_stored()
1580 if (s->lookahead <= 1) { in deflate_stored()
1582 Assert(s->strstart < s->w_size+MAX_DIST(s) || in deflate_stored()
1583 s->block_start >= (long)s->w_size, "slide too late"); in deflate_stored()
1585 fill_window(s); in deflate_stored()
1586 if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; in deflate_stored()
1588 if (s->lookahead == 0) break; /* flush the current block */ in deflate_stored()
1590 Assert(s->block_start >= 0L, "block gone"); in deflate_stored()
1592 s->strstart += s->lookahead; in deflate_stored()
1593 s->lookahead = 0; in deflate_stored()
1596 max_start = s->block_start + max_block_size; in deflate_stored()
1597 if (s->strstart == 0 || (ulg)s->strstart >= max_start) { in deflate_stored()
1599 s->lookahead = (uInt)(s->strstart - max_start); in deflate_stored()
1600 s->strstart = (uInt)max_start; in deflate_stored()
1601 FLUSH_BLOCK(s, 0); in deflate_stored()
1606 if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { in deflate_stored()
1607 FLUSH_BLOCK(s, 0); in deflate_stored()
1610 s->insert = 0; in deflate_stored()
1612 FLUSH_BLOCK(s, 1); in deflate_stored()
1615 if ((long)s->strstart > s->block_start) in deflate_stored()
1616 FLUSH_BLOCK(s, 0); in deflate_stored()
1628 deflate_state *s, in deflate_fast() argument
1640 if (s->lookahead < MIN_LOOKAHEAD) { in deflate_fast()
1641 fill_window(s); in deflate_fast()
1642 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { in deflate_fast()
1645 if (s->lookahead == 0) break; /* flush the current block */ in deflate_fast()
1652 if (s->lookahead >= MIN_MATCH) { in deflate_fast()
1653 INSERT_STRING(s, s->strstart, hash_head); in deflate_fast()
1659 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { in deflate_fast()
1664 s->match_length = longest_match (s, hash_head); in deflate_fast()
1667 if (s->match_length >= MIN_MATCH) { in deflate_fast()
1668 check_match(s, s->strstart, s->match_start, s->match_length); in deflate_fast()
1670 _tr_tally_dist(s, s->strstart - s->match_start, in deflate_fast()
1671 s->match_length - MIN_MATCH, bflush); in deflate_fast()
1673 s->lookahead -= s->match_length; in deflate_fast()
1679 if (s->match_length <= s->max_insert_length && in deflate_fast()
1680 s->lookahead >= MIN_MATCH) { in deflate_fast()
1681 s->match_length--; /* string at strstart already in table */ in deflate_fast()
1683 s->strstart++; in deflate_fast()
1684 INSERT_STRING(s, s->strstart, hash_head); in deflate_fast()
1688 } while (--s->match_length != 0); in deflate_fast()
1689 s->strstart++; in deflate_fast()
1693 s->strstart += s->match_length; in deflate_fast()
1694 s->match_length = 0; in deflate_fast()
1695 s->ins_h = s->window[s->strstart]; in deflate_fast()
1696 UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); in deflate_fast()
1706 Tracevv((stderr,"%c", s->window[s->strstart])); in deflate_fast()
1707 _tr_tally_lit (s, s->window[s->strstart], bflush); in deflate_fast()
1708 s->lookahead--; in deflate_fast()
1709 s->strstart++; in deflate_fast()
1711 if (bflush) FLUSH_BLOCK(s, 0); in deflate_fast()
1713 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; in deflate_fast()
1715 FLUSH_BLOCK(s, 1); in deflate_fast()
1718 if (s->last_lit) in deflate_fast()
1719 FLUSH_BLOCK(s, 0); in deflate_fast()
1730 deflate_state *s, in deflate_slow() argument
1743 if (s->lookahead < MIN_LOOKAHEAD) { in deflate_slow()
1744 fill_window(s); in deflate_slow()
1745 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { in deflate_slow()
1748 if (s->lookahead == 0) break; /* flush the current block */ in deflate_slow()
1755 if (s->lookahead >= MIN_MATCH) { in deflate_slow()
1756 INSERT_STRING(s, s->strstart, hash_head); in deflate_slow()
1761 s->prev_length = s->match_length, s->prev_match = s->match_start; in deflate_slow()
1762 s->match_length = MIN_MATCH-1; in deflate_slow()
1764 if (hash_head != NIL && s->prev_length < s->max_lazy_match && in deflate_slow()
1765 s->strstart - hash_head <= MAX_DIST(s)) { in deflate_slow()
1770 s->match_length = longest_match (s, hash_head); in deflate_slow()
1773 if (s->match_length <= 5 && (s->strategy == Z_FILTERED in deflate_slow()
1775 || (s->match_length == MIN_MATCH && in deflate_slow()
1776 s->strstart - s->match_start > TOO_FAR) in deflate_slow()
1783 s->match_length = MIN_MATCH-1; in deflate_slow()
1789 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { in deflate_slow()
1790 uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; in deflate_slow()
1793 check_match(s, s->strstart-1, s->prev_match, s->prev_length); in deflate_slow()
1795 _tr_tally_dist(s, s->strstart -1 - s->prev_match, in deflate_slow()
1796 s->prev_length - MIN_MATCH, bflush); in deflate_slow()
1803 s->lookahead -= s->prev_length-1; in deflate_slow()
1804 s->prev_length -= 2; in deflate_slow()
1806 if (++s->strstart <= max_insert) { in deflate_slow()
1807 INSERT_STRING(s, s->strstart, hash_head); in deflate_slow()
1809 } while (--s->prev_length != 0); in deflate_slow()
1810 s->match_available = 0; in deflate_slow()
1811 s->match_length = MIN_MATCH-1; in deflate_slow()
1812 s->strstart++; in deflate_slow()
1814 if (bflush) FLUSH_BLOCK(s, 0); in deflate_slow()
1816 } else if (s->match_available) { in deflate_slow()
1821 Tracevv((stderr,"%c", s->window[s->strstart-1])); in deflate_slow()
1822 _tr_tally_lit(s, s->window[s->strstart-1], bflush); in deflate_slow()
1824 FLUSH_BLOCK_ONLY(s, 0); in deflate_slow()
1826 s->strstart++; in deflate_slow()
1827 s->lookahead--; in deflate_slow()
1828 if (s->strm->avail_out == 0) return need_more; in deflate_slow()
1833 s->match_available = 1; in deflate_slow()
1834 s->strstart++; in deflate_slow()
1835 s->lookahead--; in deflate_slow()
1839 if (s->match_available) { in deflate_slow()
1840 Tracevv((stderr,"%c", s->window[s->strstart-1])); in deflate_slow()
1841 _tr_tally_lit(s, s->window[s->strstart-1], bflush); in deflate_slow()
1842 s->match_available = 0; in deflate_slow()
1844 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; in deflate_slow()
1846 FLUSH_BLOCK(s, 1); in deflate_slow()
1849 if (s->last_lit) in deflate_slow()
1850 FLUSH_BLOCK(s, 0); in deflate_slow()
1861 deflate_state *s, in deflate_rle() argument
1873 if (s->lookahead <= MAX_MATCH) { in deflate_rle()
1874 fill_window(s); in deflate_rle()
1875 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { in deflate_rle()
1878 if (s->lookahead == 0) break; /* flush the current block */ in deflate_rle()
1882 s->match_length = 0; in deflate_rle()
1883 if (s->lookahead >= MIN_MATCH && s->strstart > 0) { in deflate_rle()
1884 scan = s->window + s->strstart - 1; in deflate_rle()
1887 strend = s->window + s->strstart + MAX_MATCH; in deflate_rle()
1894 s->match_length = MAX_MATCH - (int)(strend - scan); in deflate_rle()
1895 if (s->match_length > s->lookahead) in deflate_rle()
1896 s->match_length = s->lookahead; in deflate_rle()
1898 Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); in deflate_rle()
1902 if (s->match_length >= MIN_MATCH) { in deflate_rle()
1903 check_match(s, s->strstart, s->strstart - 1, s->match_length); in deflate_rle()
1905 _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); in deflate_rle()
1907 s->lookahead -= s->match_length; in deflate_rle()
1908 s->strstart += s->match_length; in deflate_rle()
1909 s->match_length = 0; in deflate_rle()
1912 Tracevv((stderr,"%c", s->window[s->strstart])); in deflate_rle()
1913 _tr_tally_lit (s, s->window[s->strstart], bflush); in deflate_rle()
1914 s->lookahead--; in deflate_rle()
1915 s->strstart++; in deflate_rle()
1917 if (bflush) FLUSH_BLOCK(s, 0); in deflate_rle()
1919 s->insert = 0; in deflate_rle()
1921 FLUSH_BLOCK(s, 1); in deflate_rle()
1924 if (s->last_lit) in deflate_rle()
1925 FLUSH_BLOCK(s, 0); in deflate_rle()
1934 deflate_state *s, in deflate_huff() argument
1941 if (s->lookahead == 0) { in deflate_huff()
1942 fill_window(s); in deflate_huff()
1943 if (s->lookahead == 0) { in deflate_huff()
1951 s->match_length = 0; in deflate_huff()
1952 Tracevv((stderr,"%c", s->window[s->strstart])); in deflate_huff()
1953 _tr_tally_lit (s, s->window[s->strstart], bflush); in deflate_huff()
1954 s->lookahead--; in deflate_huff()
1955 s->strstart++; in deflate_huff()
1956 if (bflush) FLUSH_BLOCK(s, 0); in deflate_huff()
1958 s->insert = 0; in deflate_huff()
1960 FLUSH_BLOCK(s, 1); in deflate_huff()
1963 if (s->last_lit) in deflate_huff()
1964 FLUSH_BLOCK(s, 0); in deflate_huff()