Skip to content

Commit

Permalink
move things from header to .cpp to make gcc happy
Browse files Browse the repository at this point in the history
Change-Id: I5c8a4f4c56f25ebe37a21caea97312309e19729c
  • Loading branch information
garymm committed Mar 10, 2024
1 parent c4416b7 commit b29aaf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 10 additions & 0 deletions src/decompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ constexpr auto fixed_dist_table = huffman::table<
std::uint16_t,
fixed_dist_table_size>{huffman::symbol_bitsize, {{{0, 31}, 5}}};

struct LengthInfo
{
std::uint8_t extra_bits;
std::uint16_t base;
};

constexpr auto lit_or_len_end_of_block = std::uint16_t{256};
constexpr auto lit_or_len_max = std::uint16_t{285};
constexpr auto lit_or_len_max_decoded = std::uint16_t{258};

// RFC 3.2.5: Compressed blocks (length and distance codes)
constexpr auto length_infos = std::array<LengthInfo, 28>{
{{0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9},
Expand Down
14 changes: 1 addition & 13 deletions src/decompress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,9 @@ struct BlockHeader
auto read_header(huffman::bit_span& compressed_bits)
-> std::expected<BlockHeader, DecompressStatus>;

struct LengthInfo
{
std::uint8_t extra_bits;
std::uint16_t base;
};

extern const huffman::table<std::uint16_t, 288> fixed_table;
extern const std::array<LengthInfo, 28> length_infos;
constexpr auto lit_or_len_end_of_block = std::uint16_t{256};
constexpr auto lit_or_len_max = std::uint16_t{285};
constexpr auto lit_or_len_max_decoded = std::uint16_t{258};

/// Copies n bytes from (dst - distance) to dst, handling overlap by repeating.
///
/// From the standard section 3.2.3:
/// From RFC 3.2.3:
/// the referenced string may overlap the current position; for example, if the
/// last 2 bytes decoded have values X and Y, a string reference with
/// <length = 5, distance = 2> adds X,Y,X,Y,X to the output stream.
Expand Down

0 comments on commit b29aaf3

Please sign in to comment.