diff options
Diffstat (limited to 'trees.c')
-rw-r--r-- | trees.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -899,14 +899,19 @@ local void compress_block(deflate_state *s, const ct_data *ltree, | |||
899 | const ct_data *dtree) { | 899 | const ct_data *dtree) { |
900 | unsigned dist; /* distance of matched string */ | 900 | unsigned dist; /* distance of matched string */ |
901 | int lc; /* match length or unmatched char (if dist == 0) */ | 901 | int lc; /* match length or unmatched char (if dist == 0) */ |
902 | unsigned sx = 0; /* running index in sym_buf */ | 902 | unsigned sx = 0; /* running index in symbol buffers */ |
903 | unsigned code; /* the code to send */ | 903 | unsigned code; /* the code to send */ |
904 | int extra; /* number of extra bits to send */ | 904 | int extra; /* number of extra bits to send */ |
905 | 905 | ||
906 | if (s->sym_next != 0) do { | 906 | if (s->sym_next != 0) do { |
907 | #ifdef LIT_MEM | ||
908 | dist = s->d_buf[sx]; | ||
909 | lc = s->l_buf[sx++]; | ||
910 | #else | ||
907 | dist = s->sym_buf[sx++] & 0xff; | 911 | dist = s->sym_buf[sx++] & 0xff; |
908 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; | 912 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; |
909 | lc = s->sym_buf[sx++]; | 913 | lc = s->sym_buf[sx++]; |
914 | #endif | ||
910 | if (dist == 0) { | 915 | if (dist == 0) { |
911 | send_code(s, lc, ltree); /* send a literal byte */ | 916 | send_code(s, lc, ltree); /* send a literal byte */ |
912 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); | 917 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); |
@@ -931,8 +936,12 @@ local void compress_block(deflate_state *s, const ct_data *ltree, | |||
931 | } | 936 | } |
932 | } /* literal or match pair ? */ | 937 | } /* literal or match pair ? */ |
933 | 938 | ||
934 | /* Check that the overlay between pending_buf and sym_buf is ok: */ | 939 | /* Check for no overlay of pending_buf on needed symbols */ |
940 | #ifdef LIT_MEM | ||
941 | Assert(s->pending < (s->lit_bufsize << 1) + sx, "pendingBuf overflow"); | ||
942 | #else | ||
935 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); | 943 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); |
944 | #endif | ||
936 | 945 | ||
937 | } while (sx < s->sym_next); | 946 | } while (sx < s->sym_next); |
938 | 947 | ||
@@ -1082,9 +1091,14 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, | |||
1082 | * the current block must be flushed. | 1091 | * the current block must be flushed. |
1083 | */ | 1092 | */ |
1084 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { | 1093 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { |
1094 | #ifdef LIT_MEM | ||
1095 | s->d_buf[s->sym_next] = (ush)dist; | ||
1096 | s->l_buf[s->sym_next++] = (uch)lc; | ||
1097 | #else | ||
1085 | s->sym_buf[s->sym_next++] = (uch)dist; | 1098 | s->sym_buf[s->sym_next++] = (uch)dist; |
1086 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); | 1099 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
1087 | s->sym_buf[s->sym_next++] = (uch)lc; | 1100 | s->sym_buf[s->sym_next++] = (uch)lc; |
1101 | #endif | ||
1088 | if (dist == 0) { | 1102 | if (dist == 0) { |
1089 | /* lc is the unmatched char */ | 1103 | /* lc is the unmatched char */ |
1090 | s->dyn_ltree[lc].Freq++; | 1104 | s->dyn_ltree[lc].Freq++; |