Coverage Report

Created: 2026-08-31 06:47

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