aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 825d4e1..fc35c58 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,6 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+use std::mem::size_of;
use std::sync::atomic::{AtomicBool, Ordering};
use std::{env, thread};
use std::io::{prelude::*, BufReader, BufWriter};
@@ -59,7 +60,7 @@ impl<T> BufferDumper<T> {
let buf_u8: &[u8] = unsafe {
std::slice::from_raw_parts(
buf.as_ptr() as *const u8,
- buf.len() * std::mem::size_of::<T>()
+ buf.len() * size_of::<T>()
)
};
@@ -241,7 +242,7 @@ fn main() {
let mut buf_u8: &mut [u8] = unsafe {
std::slice::from_raw_parts_mut(
buf.as_mut_ptr() as *mut u8,
- buf.len() * std::mem::size_of::<i16>()
+ buf.len() * size_of::<i16>()
)
};
@@ -253,7 +254,7 @@ fn main() {
break;
}
}
- buf.resize(len, 0);
+ buf.resize(len / size_of::<i16>(), 0);
},
Err(e) => {
eprintln!("Failed to read source file: {}", e);