Coverage Report

Created: 2023-09-25 06:56

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