diff --git a/Cargo.lock b/Cargo.lock index 761163b..e4ed583 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -671,6 +671,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "shared_child" version = "0.3.4" @@ -798,6 +804,7 @@ dependencies = [ "quickcheck", "quickcheck_macros", "rand", + "safemem", "tempfile", "termion", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index a98b956..b47c1b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ num-derive = "0.3" num-traits = "0.2" quick-xml = "0.18" rand = "0.7" +safemem = "0.3.3" tempfile = "3.1" threadpool = "1.8" thiserror = "1.0" diff --git a/src/io_engine.rs b/src/io_engine.rs index f245a03..879c294 100644 --- a/src/io_engine.rs +++ b/src/io_engine.rs @@ -1,5 +1,6 @@ use io_uring::opcode::{self, types}; use io_uring::IoUring; +use safemem::write_bytes; use std::alloc::{alloc, dealloc, Layout}; use std::fs::File; use std::fs::OpenOptions; @@ -32,6 +33,12 @@ impl Block { Block { loc, data: ptr } } + pub fn zeroed(loc: u64) -> Block { + let r = Self::new(loc); + write_bytes(r.get_data(), 0); + r + } + pub fn get_data<'a>(&self) -> &'a mut [u8] { unsafe { std::slice::from_raw_parts_mut::<'a>(self.data, BLOCK_SIZE) } } diff --git a/src/report.rs b/src/report.rs index 0131f00..e105fd5 100644 --- a/src/report.rs +++ b/src/report.rs @@ -95,6 +95,7 @@ impl Report { //------------------------------------------ +#[allow(dead_code)] struct PBInner { title: String, bar: ProgressBar,