Skip to content

Commit

Permalink
Use Box for decoding tables
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Nov 30, 2024
1 parent 275afc9 commit eb0e59e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ pub const EXCEPTIONAL_ENTRY: u32 = 0x4000;
pub const SECONDARY_TABLE_ENTRY: u32 = 0x2000;

/// The Decompressor state for a compressed block.
#[repr(align(64))]
#[derive(Eq, PartialEq, Debug)]
struct CompressedBlock {
litlen_table: [u32; 4096],
litlen_table: Box<[u32; 4096]>,
secondary_table: Vec<u16>,

dist_table: [u32; 512],
dist_table: Box<[u32; 512]>,
dist_secondary_table: Vec<u16>,

eof_code: u16,
Expand Down Expand Up @@ -124,8 +123,8 @@ impl Decompressor {
buffer: 0,
nbits: 0,
compression: CompressedBlock {
litlen_table: [0; 4096],
dist_table: [0; 512],
litlen_table: Box::new([0; 4096]),
dist_table: Box::new([0; 512]),
secondary_table: Vec::new(),
dist_secondary_table: Vec::new(),
eof_code: 0,
Expand Down Expand Up @@ -411,7 +410,7 @@ impl Decompressor {
&code_lengths[..hlit],
&LITLEN_TABLE_ENTRIES,
&mut codes[..hlit],
&mut compression.litlen_table,
&mut *compression.litlen_table,
&mut compression.secondary_table,
false,
true,
Expand All @@ -433,7 +432,7 @@ impl Decompressor {
lengths,
&tables::DISTANCE_TABLE_ENTRIES,
&mut dist_codes,
&mut compression.dist_table,
&mut *compression.dist_table,
&mut compression.dist_secondary_table,
true,
false,
Expand Down

0 comments on commit eb0e59e

Please sign in to comment.