diff options
author | Andrew Gallant <jamslam@gmail.com> | 2015-04-01 09:46:11 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2015-04-01 09:46:34 -0400 |
commit | 95a217b8f441469f40ad62af43df388d97b5f72a (patch) | |
tree | 8d307e905cc87438f039b8f2941058dfb913aa99 /src | |
parent | ff6d500a0af21de46f628ae41c4620da920c41e5 (diff) | |
download | byteorder-95a217b8f441469f40ad62af43df388d97b5f72a.tar.gz |
rustup
fixes #22
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -229,39 +229,36 @@ pub type NativeEndian = BigEndian; macro_rules! read_num_bytes { ($ty:ty, $size:expr, $src:expr, $which:ident) => ({ - use std::num::Int; use std::ptr::copy_nonoverlapping; assert!($src.len() >= $size); // critical for memory safety! let mut out = [0u8; $size]; let ptr_out = out.as_mut_ptr(); unsafe { - copy_nonoverlapping(ptr_out, $src.as_ptr(), $size); + copy_nonoverlapping($src.as_ptr(), ptr_out, $size); (*(ptr_out as *const $ty)).$which() } }); ($ty:ty, $size:expr, le $bytes:expr, $src:expr, $which:ident) => ({ - use std::num::Int; use std::ptr::copy_nonoverlapping; assert!($bytes > 0 && $bytes < 9 && $bytes <= $src.len()); let mut out = [0u8; $size]; let ptr_out = out.as_mut_ptr(); unsafe { - copy_nonoverlapping(ptr_out, $src.as_ptr(), $bytes); + copy_nonoverlapping($src.as_ptr(), ptr_out, $bytes); (*(ptr_out as *const $ty)).$which() } }); ($ty:ty, $size:expr, be $bytes:expr, $src:expr, $which:ident) => ({ - use std::num::Int; use std::ptr::copy_nonoverlapping; assert!($bytes > 0 && $bytes < 9 && $bytes <= $src.len()); let mut out = [0u8; $size]; let ptr_out = out.as_mut_ptr(); unsafe { - copy_nonoverlapping(ptr_out.offset((8 - $bytes) as isize), - $src.as_ptr(), $bytes); + copy_nonoverlapping($src.as_ptr(), + ptr_out.offset((8 - $bytes) as isize), $bytes); (*(ptr_out as *const $ty)).$which() } }); @@ -269,13 +266,12 @@ macro_rules! read_num_bytes { macro_rules! write_num_bytes { ($ty:ty, $size:expr, $n:expr, $dst:expr, $which:ident) => ({ - use std::num::Int; use std::ptr::copy_nonoverlapping; assert!($dst.len() >= $size); // critical for memory safety! unsafe { let bytes = (&transmute::<_, [u8; $size]>($n.$which())).as_ptr(); - copy_nonoverlapping($dst.as_mut_ptr(), bytes, $size); + copy_nonoverlapping(bytes, $dst.as_mut_ptr(), $size); } }); } |