Skip to content

Commit

Permalink
keep bitpacked text owned before use
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonVandeVyver committed Oct 25, 2024
1 parent b91a759 commit d436dfd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libsais64-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ pub fn sais64(text: &Vec<u8>, libsais_sparseness: usize) -> Result<Vec<i64>, &st
let required_bits = libsais_sparseness * BITS_PER_CHAR;
if required_bits <= 8 {
// bitpacked values fit in uint8_t
let packed_text = if libsais_sparseness == 1 { text } else { &bitpack_text_8(text, libsais_sparseness) };
let packed_text_data;
let packed_text = if libsais_sparseness == 1 {
text
} else {
packed_text_data = bitpack_text_8(text, libsais_sparseness);
&packed_text_data
};

sa = vec![0; packed_text.len()];
exit_code =
unsafe { libsais64(packed_text.as_ptr(), sa.as_mut_ptr(), packed_text.len() as i64, 0, null_mut()) };
Expand Down

0 comments on commit d436dfd

Please sign in to comment.