Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libbz2-rs-sys/src/bzlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ pub(crate) struct DState {
pub len: [[u8; 258]; 6],
pub limit: [[i32; 258]; 6],
pub base: [[i32; 258]; 6],
pub perm: [[i32; 258]; 6],
pub perm: [[u16; 258]; 6],
pub minLens: [u8; 6],
pub save: SaveArea,
}
Expand All @@ -571,12 +571,12 @@ pub(crate) struct SaveArea {
pub alphaSize: u16,
pub EOB: u16,
pub groupNo: i32,
pub groupPos: u8,
pub nextSym: i32,
pub nblock: u32,
pub es: i32,
pub zvec: i32,
pub nextSym: u16,
pub nSelectors: u16,
pub groupPos: u8,
pub zn: u8,
pub nGroups: u8,
pub curr: u8,
Expand Down
9 changes: 5 additions & 4 deletions libbz2-rs-sys/src/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ pub(crate) fn decompress(
Some(&nextSym) => nextSym,
None => error!(BZ_DATA_ERROR),
};
if nextSym == BZ_RUNA as i32 || nextSym == BZ_RUNB as i32 {
if nextSym == BZ_RUNA || nextSym == BZ_RUNB {
current_block = Block46;
} else {
es += 1;
Expand Down Expand Up @@ -842,10 +842,10 @@ pub(crate) fn decompress(
_ => {}
}
if current_block == Block40 {
if nextSym == EOB as i32 {
if nextSym == EOB {
current_block = Block41;
} else {
if nextSym == 0 || nextSym == 1 {
if nextSym == BZ_RUNA || nextSym == BZ_RUNB {
es = -1;
logN = 0;
} else if nblock >= 100000 * nblockMAX100k as u32 {
Expand Down Expand Up @@ -1116,7 +1116,7 @@ pub(crate) fn decompress(
if logN >= LOG_2MB {
error!(BZ_DATA_ERROR);
} else {
let mul = match nextSym as u16 {
let mul = match nextSym {
BZ_RUNA => 1,
BZ_RUNB => 2,
_ => 0,
Expand Down Expand Up @@ -1254,6 +1254,7 @@ pub(crate) fn decompress(

/*--- Create the Huffman decoding tables ---*/
for t in 0..nGroups as usize {
// NOTE: s.nInUse <= 256, alphaSize <= 258
let len = &s.len[t][..alphaSize as usize];

let mut minLen = 32u8;
Expand Down
10 changes: 6 additions & 4 deletions libbz2-rs-sys/src/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,20 @@ pub(crate) fn assign_codes(

#[inline(always)]
pub(crate) fn create_decode_tables(
limit: &mut [i32],
base: &mut [i32],
perm: &mut [i32],
limit: &mut [i32; 258],
base: &mut [i32; 258],
perm: &mut [u16; 258],
length: &[u8],
minLen: u8,
maxLen: u8,
) {
assert!(length.len() <= 258);

let mut pp: i32 = 0;
for i in minLen..=maxLen {
for (j, e) in length.iter().enumerate() {
if *e == i {
perm[pp as usize] = j as i32;
perm[pp as usize] = j as u16;
pp += 1;
}
}
Expand Down