Coverage Report

Created: 2025-11-13 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zlib-ng/deflate_huff.c
Line
Count
Source
1
/* deflate_huff.c -- compress data using huffman encoding only strategy
2
 *
3
 * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
4
 * For conditions of distribution and use, see copyright notice in zlib.h
5
 */
6
7
#include "zbuild.h"
8
#include "deflate.h"
9
#include "deflate_p.h"
10
#include "functable.h"
11
12
/* ===========================================================================
13
 * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
14
 * (It will be regenerated if this run of deflate switches away from Huffman.)
15
 */
16
1.12k
Z_INTERNAL block_state deflate_huff(deflate_state *s, int flush) {
17
1.12k
    int bflush = 0;         /* set if current block must be flushed */
18
19
4.80M
    for (;;) {
20
        /* Make sure that we have a literal to write. */
21
4.80M
        if (s->lookahead == 0) {
22
6.92k
            PREFIX(fill_window)(s);
23
6.92k
            if (s->lookahead == 0) {
24
1.12k
                if (flush == Z_NO_FLUSH)
25
0
                    return need_more;
26
1.12k
                break;      /* flush the current block */
27
1.12k
            }
28
6.92k
        }
29
30
        /* Output a literal byte */
31
4.80M
        bflush = zng_tr_tally_lit(s, s->window[s->strstart]);
32
4.80M
        s->lookahead--;
33
4.80M
        s->strstart++;
34
4.80M
        if (bflush)
35
4.80M
            FLUSH_BLOCK(s, 0);
36
4.80M
    }
37
1.12k
    s->insert = 0;
38
1.12k
    if (flush == Z_FINISH) {
39
1.12k
        FLUSH_BLOCK(s, 1);
40
1.12k
        return finish_done;
41
1.12k
    }
42
0
    if (s->sym_next)
43
0
        FLUSH_BLOCK(s, 0);
44
0
    return block_done;
45
0
}