diff options
| -rw-r--r-- | trees.c | 37 |
1 files changed, 7 insertions, 30 deletions
| @@ -152,8 +152,6 @@ local int detect_data_type OF((deflate_state *s)); | |||
| 152 | local unsigned bi_reverse OF((unsigned value, int length)); | 152 | local unsigned bi_reverse OF((unsigned value, int length)); |
| 153 | local void bi_windup OF((deflate_state *s)); | 153 | local void bi_windup OF((deflate_state *s)); |
| 154 | local void bi_flush OF((deflate_state *s)); | 154 | local void bi_flush OF((deflate_state *s)); |
| 155 | local void copy_block OF((deflate_state *s, charf *buf, unsigned len, | ||
| 156 | int header)); | ||
| 157 | 155 | ||
| 158 | #ifdef GEN_TREES_H | 156 | #ifdef GEN_TREES_H |
| 159 | local void gen_trees_header OF((void)); | 157 | local void gen_trees_header OF((void)); |
| @@ -869,11 +867,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
| 869 | int last; /* one if this is the last block for a file */ | 867 | int last; /* one if this is the last block for a file */ |
| 870 | { | 868 | { |
| 871 | send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ | 869 | send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ |
| 870 | bi_windup(s); /* align on byte boundary */ | ||
| 871 | put_short(s, (ush)stored_len); | ||
| 872 | put_short(s, (ush)~stored_len); | ||
| 873 | zmemcpy(s->pending_buf + s->pending, buf, stored_len); | ||
| 874 | s->pending += stored_len; | ||
| 872 | #ifdef ZLIB_DEBUG | 875 | #ifdef ZLIB_DEBUG |
| 873 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; | 876 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; |
| 874 | s->compressed_len += (stored_len + 4) << 3; | 877 | s->compressed_len += (stored_len + 4) << 3; |
| 878 | s->bits_sent += 2*16; | ||
| 879 | s->bits_sent += stored_len<<3; | ||
| 875 | #endif | 880 | #endif |
| 876 | copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ | ||
| 877 | } | 881 | } |
| 878 | 882 | ||
| 879 | /* =========================================================================== | 883 | /* =========================================================================== |
| @@ -1197,30 +1201,3 @@ local void bi_windup(s) | |||
| 1197 | s->bits_sent = (s->bits_sent+7) & ~7; | 1201 | s->bits_sent = (s->bits_sent+7) & ~7; |
| 1198 | #endif | 1202 | #endif |
| 1199 | } | 1203 | } |
| 1200 | |||
| 1201 | /* =========================================================================== | ||
| 1202 | * Copy a stored block, storing first the length and its | ||
| 1203 | * one's complement if requested. | ||
| 1204 | */ | ||
| 1205 | local void copy_block(s, buf, len, header) | ||
| 1206 | deflate_state *s; | ||
| 1207 | charf *buf; /* the input data */ | ||
| 1208 | unsigned len; /* its length */ | ||
| 1209 | int header; /* true if block header must be written */ | ||
| 1210 | { | ||
| 1211 | bi_windup(s); /* align on byte boundary */ | ||
| 1212 | |||
| 1213 | if (header) { | ||
| 1214 | put_short(s, (ush)len); | ||
| 1215 | put_short(s, (ush)~len); | ||
| 1216 | #ifdef ZLIB_DEBUG | ||
| 1217 | s->bits_sent += 2*16; | ||
| 1218 | #endif | ||
| 1219 | } | ||
| 1220 | #ifdef ZLIB_DEBUG | ||
| 1221 | s->bits_sent += (ulg)len<<3; | ||
| 1222 | #endif | ||
| 1223 | while (len--) { | ||
| 1224 | put_byte(s, *buf++); | ||
| 1225 | } | ||
| 1226 | } | ||
