Line | Count | Source (jump to first uncovered line) |
1 | | /* deflate_p.h -- Private inline functions and macros shared with more than |
2 | | * one deflate method |
3 | | * |
4 | | * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler |
5 | | * For conditions of distribution and use, see copyright notice in zlib.h |
6 | | * |
7 | | */ |
8 | | |
9 | | #ifndef DEFLATE_P_H |
10 | | #define DEFLATE_P_H |
11 | | |
12 | | #include "functable.h" |
13 | | |
14 | | /* Forward declare common non-inlined functions declared in deflate.c */ |
15 | | |
16 | | #ifdef ZLIB_DEBUG |
17 | | /* =========================================================================== |
18 | | * Check that the match at match_start is indeed a match. |
19 | | */ |
20 | | static inline void check_match(deflate_state *s, Pos start, Pos match, int length) { |
21 | | /* check that the match length is valid*/ |
22 | | if (length < STD_MIN_MATCH || length > STD_MAX_MATCH) { |
23 | | fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); |
24 | | z_error("invalid match length"); |
25 | | } |
26 | | /* check that the match isn't at the same position as the start string */ |
27 | | if (match == start) { |
28 | | fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); |
29 | | z_error("invalid match position"); |
30 | | } |
31 | | /* check that the match is indeed a match */ |
32 | | if (memcmp(s->window + match, s->window + start, length) != 0) { |
33 | | int32_t i = 0; |
34 | | fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); |
35 | | do { |
36 | | fprintf(stderr, " %03d: match [%02x] start [%02x]\n", i++, |
37 | | s->window[match++], s->window[start++]); |
38 | | } while (--length != 0); |
39 | | z_error("invalid match"); |
40 | | } |
41 | | if (z_verbose > 1) { |
42 | | fprintf(stderr, "\\[%u,%d]", start-match, length); |
43 | | do { |
44 | | putc(s->window[start++], stderr); |
45 | | } while (--length != 0); |
46 | | } |
47 | | } |
48 | | #else |
49 | | #define check_match(s, start, match, length) |
50 | | #endif |
51 | | |
52 | | Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm); |
53 | | |
54 | | /* =========================================================================== |
55 | | * Save the match info and tally the frequency counts. Return true if |
56 | | * the current block must be flushed. |
57 | | */ |
58 | | |
59 | | extern const unsigned char Z_INTERNAL zng_length_code[]; |
60 | | extern const unsigned char Z_INTERNAL zng_dist_code[]; |
61 | | |
62 | 705M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { |
63 | | /* c is the unmatched char */ |
64 | 705M | #ifdef LIT_MEM |
65 | 705M | s->d_buf[s->sym_next] = 0; |
66 | 705M | s->l_buf[s->sym_next++] = c; |
67 | | #else |
68 | | s->sym_buf[s->sym_next++] = 0; |
69 | | s->sym_buf[s->sym_next++] = 0; |
70 | | s->sym_buf[s->sym_next++] = c; |
71 | | #endif |
72 | 705M | s->dyn_ltree[c].Freq++; |
73 | 705M | Tracevv((stderr, "%c", c)); |
74 | 705M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); |
75 | 705M | return (s->sym_next == s->sym_end); |
76 | 705M | } Unexecuted instantiation: deflate.c:zng_tr_tally_lit deflate_fast.c:zng_tr_tally_lit Line | Count | Source | 62 | 11.0M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { | 63 | | /* c is the unmatched char */ | 64 | 11.0M | #ifdef LIT_MEM | 65 | 11.0M | s->d_buf[s->sym_next] = 0; | 66 | 11.0M | s->l_buf[s->sym_next++] = c; | 67 | | #else | 68 | | s->sym_buf[s->sym_next++] = 0; | 69 | | s->sym_buf[s->sym_next++] = 0; | 70 | | s->sym_buf[s->sym_next++] = c; | 71 | | #endif | 72 | 11.0M | s->dyn_ltree[c].Freq++; | 73 | 11.0M | Tracevv((stderr, "%c", c)); | 74 | 11.0M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); | 75 | 11.0M | return (s->sym_next == s->sym_end); | 76 | 11.0M | } |
deflate_huff.c:zng_tr_tally_lit Line | Count | Source | 62 | 80.6M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { | 63 | | /* c is the unmatched char */ | 64 | 80.6M | #ifdef LIT_MEM | 65 | 80.6M | s->d_buf[s->sym_next] = 0; | 66 | 80.6M | s->l_buf[s->sym_next++] = c; | 67 | | #else | 68 | | s->sym_buf[s->sym_next++] = 0; | 69 | | s->sym_buf[s->sym_next++] = 0; | 70 | | s->sym_buf[s->sym_next++] = c; | 71 | | #endif | 72 | 80.6M | s->dyn_ltree[c].Freq++; | 73 | 80.6M | Tracevv((stderr, "%c", c)); | 74 | 80.6M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); | 75 | 80.6M | return (s->sym_next == s->sym_end); | 76 | 80.6M | } |
deflate_medium.c:zng_tr_tally_lit Line | Count | Source | 62 | 439M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { | 63 | | /* c is the unmatched char */ | 64 | 439M | #ifdef LIT_MEM | 65 | 439M | s->d_buf[s->sym_next] = 0; | 66 | 439M | s->l_buf[s->sym_next++] = c; | 67 | | #else | 68 | | s->sym_buf[s->sym_next++] = 0; | 69 | | s->sym_buf[s->sym_next++] = 0; | 70 | | s->sym_buf[s->sym_next++] = c; | 71 | | #endif | 72 | 439M | s->dyn_ltree[c].Freq++; | 73 | 439M | Tracevv((stderr, "%c", c)); | 74 | 439M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); | 75 | 439M | return (s->sym_next == s->sym_end); | 76 | 439M | } |
Unexecuted instantiation: deflate_quick.c:zng_tr_tally_lit deflate_rle.c:zng_tr_tally_lit Line | Count | Source | 62 | 49.9M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { | 63 | | /* c is the unmatched char */ | 64 | 49.9M | #ifdef LIT_MEM | 65 | 49.9M | s->d_buf[s->sym_next] = 0; | 66 | 49.9M | s->l_buf[s->sym_next++] = c; | 67 | | #else | 68 | | s->sym_buf[s->sym_next++] = 0; | 69 | | s->sym_buf[s->sym_next++] = 0; | 70 | | s->sym_buf[s->sym_next++] = c; | 71 | | #endif | 72 | 49.9M | s->dyn_ltree[c].Freq++; | 73 | 49.9M | Tracevv((stderr, "%c", c)); | 74 | 49.9M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); | 75 | 49.9M | return (s->sym_next == s->sym_end); | 76 | 49.9M | } |
deflate_slow.c:zng_tr_tally_lit Line | Count | Source | 62 | 124M | static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) { | 63 | | /* c is the unmatched char */ | 64 | 124M | #ifdef LIT_MEM | 65 | 124M | s->d_buf[s->sym_next] = 0; | 66 | 124M | s->l_buf[s->sym_next++] = c; | 67 | | #else | 68 | | s->sym_buf[s->sym_next++] = 0; | 69 | | s->sym_buf[s->sym_next++] = 0; | 70 | | s->sym_buf[s->sym_next++] = c; | 71 | | #endif | 72 | 124M | s->dyn_ltree[c].Freq++; | 73 | 124M | Tracevv((stderr, "%c", c)); | 74 | 124M | Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal"); | 75 | 124M | return (s->sym_next == s->sym_end); | 76 | 124M | } |
Unexecuted instantiation: deflate_stored.c:zng_tr_tally_lit Unexecuted instantiation: trees.c:zng_tr_tally_lit |
77 | | |
78 | 30.8M | static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) { |
79 | | /* dist: distance of matched string */ |
80 | | /* len: match length-STD_MIN_MATCH */ |
81 | 30.8M | #ifdef LIT_MEM |
82 | 30.8M | Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); |
83 | 30.8M | Assert(len <= UINT8_MAX, "len should fit in uint8_t"); |
84 | 30.8M | s->d_buf[s->sym_next] = (uint16_t)dist; |
85 | 30.8M | s->l_buf[s->sym_next++] = (uint8_t)len; |
86 | | #else |
87 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist); |
88 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); |
89 | | s->sym_buf[s->sym_next++] = (uint8_t)len; |
90 | | #endif |
91 | 30.8M | s->matches++; |
92 | 30.8M | dist--; |
93 | 30.8M | Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, |
94 | 30.8M | "zng_tr_tally: bad match"); |
95 | | |
96 | 30.8M | s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++; |
97 | 30.8M | s->dyn_dtree[d_code(dist)].Freq++; |
98 | 30.8M | return (s->sym_next == s->sym_end); |
99 | 30.8M | } Unexecuted instantiation: deflate.c:zng_tr_tally_dist deflate_fast.c:zng_tr_tally_dist Line | Count | Source | 78 | 1.44M | static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) { | 79 | | /* dist: distance of matched string */ | 80 | | /* len: match length-STD_MIN_MATCH */ | 81 | 1.44M | #ifdef LIT_MEM | 82 | 1.44M | Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); | 83 | 1.44M | Assert(len <= UINT8_MAX, "len should fit in uint8_t"); | 84 | 1.44M | s->d_buf[s->sym_next] = (uint16_t)dist; | 85 | 1.44M | s->l_buf[s->sym_next++] = (uint8_t)len; | 86 | | #else | 87 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist); | 88 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); | 89 | | s->sym_buf[s->sym_next++] = (uint8_t)len; | 90 | | #endif | 91 | 1.44M | s->matches++; | 92 | 1.44M | dist--; | 93 | 1.44M | Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, | 94 | 1.44M | "zng_tr_tally: bad match"); | 95 | | | 96 | 1.44M | s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++; | 97 | 1.44M | s->dyn_dtree[d_code(dist)].Freq++; | 98 | 1.44M | return (s->sym_next == s->sym_end); | 99 | 1.44M | } |
Unexecuted instantiation: deflate_huff.c:zng_tr_tally_dist deflate_medium.c:zng_tr_tally_dist Line | Count | Source | 78 | 17.9M | static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) { | 79 | | /* dist: distance of matched string */ | 80 | | /* len: match length-STD_MIN_MATCH */ | 81 | 17.9M | #ifdef LIT_MEM | 82 | 17.9M | Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); | 83 | 17.9M | Assert(len <= UINT8_MAX, "len should fit in uint8_t"); | 84 | 17.9M | s->d_buf[s->sym_next] = (uint16_t)dist; | 85 | 17.9M | s->l_buf[s->sym_next++] = (uint8_t)len; | 86 | | #else | 87 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist); | 88 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); | 89 | | s->sym_buf[s->sym_next++] = (uint8_t)len; | 90 | | #endif | 91 | 17.9M | s->matches++; | 92 | 17.9M | dist--; | 93 | 17.9M | Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, | 94 | 17.9M | "zng_tr_tally: bad match"); | 95 | | | 96 | 17.9M | s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++; | 97 | 17.9M | s->dyn_dtree[d_code(dist)].Freq++; | 98 | 17.9M | return (s->sym_next == s->sym_end); | 99 | 17.9M | } |
Unexecuted instantiation: deflate_quick.c:zng_tr_tally_dist deflate_rle.c:zng_tr_tally_dist Line | Count | Source | 78 | 1.52M | static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) { | 79 | | /* dist: distance of matched string */ | 80 | | /* len: match length-STD_MIN_MATCH */ | 81 | 1.52M | #ifdef LIT_MEM | 82 | 1.52M | Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); | 83 | 1.52M | Assert(len <= UINT8_MAX, "len should fit in uint8_t"); | 84 | 1.52M | s->d_buf[s->sym_next] = (uint16_t)dist; | 85 | 1.52M | s->l_buf[s->sym_next++] = (uint8_t)len; | 86 | | #else | 87 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist); | 88 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); | 89 | | s->sym_buf[s->sym_next++] = (uint8_t)len; | 90 | | #endif | 91 | 1.52M | s->matches++; | 92 | 1.52M | dist--; | 93 | 1.52M | Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, | 94 | 1.52M | "zng_tr_tally: bad match"); | 95 | | | 96 | 1.52M | s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++; | 97 | 1.52M | s->dyn_dtree[d_code(dist)].Freq++; | 98 | 1.52M | return (s->sym_next == s->sym_end); | 99 | 1.52M | } |
deflate_slow.c:zng_tr_tally_dist Line | Count | Source | 78 | 9.96M | static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) { | 79 | | /* dist: distance of matched string */ | 80 | | /* len: match length-STD_MIN_MATCH */ | 81 | 9.96M | #ifdef LIT_MEM | 82 | 9.96M | Assert(dist <= UINT16_MAX, "dist should fit in uint16_t"); | 83 | 9.96M | Assert(len <= UINT8_MAX, "len should fit in uint8_t"); | 84 | 9.96M | s->d_buf[s->sym_next] = (uint16_t)dist; | 85 | 9.96M | s->l_buf[s->sym_next++] = (uint8_t)len; | 86 | | #else | 87 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist); | 88 | | s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8); | 89 | | s->sym_buf[s->sym_next++] = (uint8_t)len; | 90 | | #endif | 91 | 9.96M | s->matches++; | 92 | 9.96M | dist--; | 93 | 9.96M | Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES, | 94 | 9.96M | "zng_tr_tally: bad match"); | 95 | | | 96 | 9.96M | s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++; | 97 | 9.96M | s->dyn_dtree[d_code(dist)].Freq++; | 98 | 9.96M | return (s->sym_next == s->sym_end); | 99 | 9.96M | } |
Unexecuted instantiation: deflate_stored.c:zng_tr_tally_dist Unexecuted instantiation: trees.c:zng_tr_tally_dist |
100 | | |
101 | | /* ========================================================================= |
102 | | * Flush as much pending output as possible. All deflate() output, except for some |
103 | | * deflate_stored() output, goes through this function so some applications may wish to |
104 | | * modify it to avoid allocating a large strm->next_out buffer and copying into it. |
105 | | * See also read_buf(). |
106 | | */ |
107 | 101M | Z_FORCEINLINE static void flush_pending_inline(PREFIX3(stream) *strm) { |
108 | 101M | uint32_t len; |
109 | 101M | deflate_state *s = strm->state; |
110 | | |
111 | 101M | zng_tr_flush_bits(s); |
112 | 101M | len = MIN(s->pending, strm->avail_out); |
113 | 101M | if (len == 0) |
114 | 11.0k | return; |
115 | | |
116 | 101M | Tracev((stderr, "[FLUSH]")); |
117 | 101M | memcpy(strm->next_out, s->pending_out, len); |
118 | 101M | strm->next_out += len; |
119 | 101M | s->pending_out += len; |
120 | 101M | strm->total_out += len; |
121 | 101M | strm->avail_out -= len; |
122 | 101M | s->pending -= len; |
123 | 101M | if (s->pending == 0) |
124 | 208k | s->pending_out = s->pending_buf; |
125 | 101M | } deflate.c:flush_pending_inline Line | Count | Source | 107 | 101M | Z_FORCEINLINE static void flush_pending_inline(PREFIX3(stream) *strm) { | 108 | 101M | uint32_t len; | 109 | 101M | deflate_state *s = strm->state; | 110 | | | 111 | 101M | zng_tr_flush_bits(s); | 112 | 101M | len = MIN(s->pending, strm->avail_out); | 113 | 101M | if (len == 0) | 114 | 11.0k | return; | 115 | | | 116 | 101M | Tracev((stderr, "[FLUSH]")); | 117 | 101M | memcpy(strm->next_out, s->pending_out, len); | 118 | 101M | strm->next_out += len; | 119 | 101M | s->pending_out += len; | 120 | 101M | strm->total_out += len; | 121 | 101M | strm->avail_out -= len; | 122 | 101M | s->pending -= len; | 123 | 101M | if (s->pending == 0) | 124 | 208k | s->pending_out = s->pending_buf; | 125 | 101M | } |
Unexecuted instantiation: deflate_fast.c:flush_pending_inline Unexecuted instantiation: deflate_huff.c:flush_pending_inline Unexecuted instantiation: deflate_medium.c:flush_pending_inline Unexecuted instantiation: deflate_quick.c:flush_pending_inline Unexecuted instantiation: deflate_rle.c:flush_pending_inline Unexecuted instantiation: deflate_slow.c:flush_pending_inline Unexecuted instantiation: deflate_stored.c:flush_pending_inline Unexecuted instantiation: trees.c:flush_pending_inline |
126 | | |
127 | | /* =========================================================================== |
128 | | * Reverse the first len bits of a code using bit manipulation |
129 | | */ |
130 | 15.2M | static inline uint16_t bi_reverse(unsigned code, int len) { |
131 | | /* code: the value to invert */ |
132 | | /* len: its bit length */ |
133 | 15.2M | Assert(len >= 1 && len <= 15, "code length must be 1-15"); |
134 | 15.2M | #define bitrev8(b) \ |
135 | 30.5M | (uint8_t)((((uint8_t)(b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32) |
136 | 15.2M | return (bitrev8(code >> 8) | (uint16_t)bitrev8(code) << 8) >> (16 - len); |
137 | 15.2M | } Unexecuted instantiation: deflate.c:bi_reverse Unexecuted instantiation: deflate_fast.c:bi_reverse Unexecuted instantiation: deflate_huff.c:bi_reverse Unexecuted instantiation: deflate_medium.c:bi_reverse Unexecuted instantiation: deflate_quick.c:bi_reverse Unexecuted instantiation: deflate_rle.c:bi_reverse Unexecuted instantiation: deflate_slow.c:bi_reverse Unexecuted instantiation: deflate_stored.c:bi_reverse Line | Count | Source | 130 | 15.2M | static inline uint16_t bi_reverse(unsigned code, int len) { | 131 | | /* code: the value to invert */ | 132 | | /* len: its bit length */ | 133 | 15.2M | Assert(len >= 1 && len <= 15, "code length must be 1-15"); | 134 | 15.2M | #define bitrev8(b) \ | 135 | 15.2M | (uint8_t)((((uint8_t)(b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32) | 136 | 15.2M | return (bitrev8(code >> 8) | (uint16_t)bitrev8(code) << 8) >> (16 - len); | 137 | 15.2M | } |
|
138 | | |
139 | | /* =========================================================================== |
140 | | * Read a new buffer from the current input stream, update the adler32 and total number of |
141 | | * bytes read. All deflate() input goes through this function so some applications may wish |
142 | | * to modify it to avoid allocating a large strm->next_in buffer and copying from it. |
143 | | * See also flush_pending_inline(). |
144 | | */ |
145 | 148M | Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { |
146 | 148M | deflate_state *s = strm->state; |
147 | 148M | uint32_t len = MIN(strm->avail_in, size); |
148 | | |
149 | 148M | if (len == 0) |
150 | 0 | return 0; |
151 | | |
152 | 148M | if (!DEFLATE_NEED_CHECKSUM(strm)) { |
153 | 0 | memcpy(buf, strm->next_in, len); |
154 | 0 | #ifdef GZIP |
155 | 148M | } else if (s->wrap == 2) { |
156 | 14.6k | FUNCTABLE_CALL(crc32_fold_copy)(&s->crc_fold, buf, strm->next_in, len); |
157 | 14.6k | #endif |
158 | 148M | } else if (s->wrap == 1) { |
159 | 148M | strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len); |
160 | 148M | } else { |
161 | 6.48k | memcpy(buf, strm->next_in, len); |
162 | 6.48k | } |
163 | | |
164 | 148M | strm->avail_in -= len; |
165 | 148M | strm->next_in += len; |
166 | 148M | strm->total_in += len; |
167 | 148M | return len; |
168 | 148M | } Line | Count | Source | 145 | 148M | Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { | 146 | 148M | deflate_state *s = strm->state; | 147 | 148M | uint32_t len = MIN(strm->avail_in, size); | 148 | | | 149 | 148M | if (len == 0) | 150 | 0 | return 0; | 151 | | | 152 | 148M | if (!DEFLATE_NEED_CHECKSUM(strm)) { | 153 | 0 | memcpy(buf, strm->next_in, len); | 154 | 0 | #ifdef GZIP | 155 | 148M | } else if (s->wrap == 2) { | 156 | 13.8k | FUNCTABLE_CALL(crc32_fold_copy)(&s->crc_fold, buf, strm->next_in, len); | 157 | 13.8k | #endif | 158 | 148M | } else if (s->wrap == 1) { | 159 | 148M | strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len); | 160 | 148M | } else { | 161 | 6.48k | memcpy(buf, strm->next_in, len); | 162 | 6.48k | } | 163 | | | 164 | 148M | strm->avail_in -= len; | 165 | 148M | strm->next_in += len; | 166 | 148M | strm->total_in += len; | 167 | 148M | return len; | 168 | 148M | } |
Unexecuted instantiation: deflate_fast.c:read_buf Unexecuted instantiation: deflate_huff.c:read_buf Unexecuted instantiation: deflate_medium.c:read_buf Unexecuted instantiation: deflate_quick.c:read_buf Unexecuted instantiation: deflate_rle.c:read_buf Unexecuted instantiation: deflate_slow.c:read_buf deflate_stored.c:read_buf Line | Count | Source | 145 | 2.26k | Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { | 146 | 2.26k | deflate_state *s = strm->state; | 147 | 2.26k | uint32_t len = MIN(strm->avail_in, size); | 148 | | | 149 | 2.26k | if (len == 0) | 150 | 0 | return 0; | 151 | | | 152 | 2.26k | if (!DEFLATE_NEED_CHECKSUM(strm)) { | 153 | 0 | memcpy(buf, strm->next_in, len); | 154 | 0 | #ifdef GZIP | 155 | 2.26k | } else if (s->wrap == 2) { | 156 | 836 | FUNCTABLE_CALL(crc32_fold_copy)(&s->crc_fold, buf, strm->next_in, len); | 157 | 836 | #endif | 158 | 1.42k | } else if (s->wrap == 1) { | 159 | 1.42k | strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len); | 160 | 1.42k | } else { | 161 | 0 | memcpy(buf, strm->next_in, len); | 162 | 0 | } | 163 | | | 164 | 2.26k | strm->avail_in -= len; | 165 | 2.26k | strm->next_in += len; | 166 | 2.26k | strm->total_in += len; | 167 | 2.26k | return len; | 168 | 2.26k | } |
Unexecuted instantiation: trees.c:read_buf |
169 | | |
170 | | /* =========================================================================== |
171 | | * Flush the current block, with given end-of-file flag. |
172 | | * IN assertion: strstart is set to the end of the current match. |
173 | | */ |
174 | 122k | #define FLUSH_BLOCK_ONLY(s, last) { \ |
175 | 122k | zng_tr_flush_block(s, (s->block_start >= 0 ? \ |
176 | 122k | (char *)&s->window[(unsigned)s->block_start] : \ |
177 | 122k | NULL), \ |
178 | 122k | (uint32_t)((int)s->strstart - s->block_start), \ |
179 | 122k | (last)); \ |
180 | 122k | s->block_start = (int)s->strstart; \ |
181 | 122k | PREFIX(flush_pending)(s->strm); \ |
182 | 122k | } |
183 | | |
184 | | /* Same but force premature exit if necessary. */ |
185 | 109k | #define FLUSH_BLOCK(s, last) { \ |
186 | 109k | FLUSH_BLOCK_ONLY(s, last); \ |
187 | 109k | if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ |
188 | 109k | } |
189 | | |
190 | | /* Maximum stored block length in deflate format (not including header). */ |
191 | 5.12k | #define MAX_STORED 65535 |
192 | | |
193 | | /* Compression function. Returns the block state after the call. */ |
194 | | typedef block_state (*compress_func) (deflate_state *s, int flush); |
195 | | /* Match function. Returns the longest match. */ |
196 | | typedef uint32_t (*match_func) (deflate_state *const s, Pos cur_match); |
197 | | |
198 | | #endif |