Coverage Report

Created: 2025-11-16 07:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/xz/src/liblzma/common/index.h
Line
Count
Source
1
// SPDX-License-Identifier: 0BSD
2
3
///////////////////////////////////////////////////////////////////////////////
4
//
5
/// \file       index.h
6
/// \brief      Handling of Index
7
/// \note       This header file does not include common.h or lzma.h because
8
///             this file is needed by both liblzma internally and by the
9
///             tests. Including common.h will include and define many things
10
///             the tests do not need and prevents issues with header file
11
///             include order. This way, if lzma.h or common.h are not
12
///             included before this file it will break on every OS instead
13
///             of causing more subtle errors.
14
//
15
//  Author:     Lasse Collin
16
//
17
///////////////////////////////////////////////////////////////////////////////
18
19
#ifndef LZMA_INDEX_H
20
#define LZMA_INDEX_H
21
22
23
/// Minimum Unpadded Size
24
1.60k
#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
25
26
/// Maximum Unpadded Size
27
6.32k
#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
28
29
/// Index Indicator based on xz specification
30
5.50k
#define INDEX_INDICATOR 0
31
32
33
/// Get the size of the Index Padding field. This is needed by Index encoder
34
/// and decoder, but applications should have no use for this.
35
extern uint32_t lzma_index_padding_size(const lzma_index *i);
36
37
38
/// Set for how many Records to allocate memory the next time
39
/// lzma_index_append() needs to allocate space for a new Record.
40
/// This is used only by the Index decoder.
41
extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);
42
43
44
/// Round the variable-length integer to the next multiple of four.
45
static inline lzma_vli
46
vli_ceil4(lzma_vli vli)
47
12.3k
{
48
12.3k
  assert(vli <= UNPADDED_SIZE_MAX);
49
12.3k
  return (vli + 3) & ~LZMA_VLI_C(3);
50
12.3k
}
Unexecuted instantiation: stream_decoder.c:vli_ceil4
Unexecuted instantiation: block_util.c:vli_ceil4
index.c:vli_ceil4
Line
Count
Source
47
12.2k
{
48
12.2k
  assert(vli <= UNPADDED_SIZE_MAX);
49
  return (vli + 3) & ~LZMA_VLI_C(3);
50
12.2k
}
Unexecuted instantiation: index_encoder.c:vli_ceil4
index_hash.c:vli_ceil4
Line
Count
Source
47
192
{
48
192
  assert(vli <= UNPADDED_SIZE_MAX);
49
  return (vli + 3) & ~LZMA_VLI_C(3);
50
192
}
51
52
53
/// Calculate the size of the Index field excluding Index Padding
54
static inline lzma_vli
55
index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
56
7.76k
{
57
  // Index Indicator + Number of Records + List of Records + CRC32
58
7.76k
  return 1 + lzma_vli_size(count) + index_list_size + 4;
59
7.76k
}
Unexecuted instantiation: stream_decoder.c:index_size_unpadded
Unexecuted instantiation: block_util.c:index_size_unpadded
index.c:index_size_unpadded
Line
Count
Source
56
7.62k
{
57
  // Index Indicator + Number of Records + List of Records + CRC32
58
7.62k
  return 1 + lzma_vli_size(count) + index_list_size + 4;
59
7.62k
}
Unexecuted instantiation: index_encoder.c:index_size_unpadded
index_hash.c:index_size_unpadded
Line
Count
Source
56
141
{
57
  // Index Indicator + Number of Records + List of Records + CRC32
58
141
  return 1 + lzma_vli_size(count) + index_list_size + 4;
59
141
}
60
61
62
/// Calculate the size of the Index field including Index Padding
63
static inline lzma_vli
64
index_size(lzma_vli count, lzma_vli index_list_size)
65
6.22k
{
66
6.22k
  return vli_ceil4(index_size_unpadded(count, index_list_size));
67
6.22k
}
Unexecuted instantiation: stream_decoder.c:index_size
Unexecuted instantiation: block_util.c:index_size
index.c:index_size
Line
Count
Source
65
6.10k
{
66
6.10k
  return vli_ceil4(index_size_unpadded(count, index_list_size));
67
6.10k
}
Unexecuted instantiation: index_encoder.c:index_size
index_hash.c:index_size
Line
Count
Source
65
120
{
66
120
  return vli_ceil4(index_size_unpadded(count, index_list_size));
67
120
}
68
69
70
/// Calculate the total size of the Stream
71
static inline lzma_vli
72
index_stream_size(lzma_vli blocks_size,
73
    lzma_vli count, lzma_vli index_list_size)
74
60
{
75
60
  return LZMA_STREAM_HEADER_SIZE + blocks_size
76
60
      + index_size(count, index_list_size)
77
60
      + LZMA_STREAM_HEADER_SIZE;
78
60
}
Unexecuted instantiation: stream_decoder.c:index_stream_size
Unexecuted instantiation: block_util.c:index_stream_size
Unexecuted instantiation: index.c:index_stream_size
Unexecuted instantiation: index_encoder.c:index_stream_size
index_hash.c:index_stream_size
Line
Count
Source
74
60
{
75
60
  return LZMA_STREAM_HEADER_SIZE + blocks_size
76
60
      + index_size(count, index_list_size)
77
60
      + LZMA_STREAM_HEADER_SIZE;
78
60
}
79
80
#endif