|
|
@ -1,6 +1,5 @@
|
|
|
|
use libc::{
|
|
|
|
use std::ptr;
|
|
|
|
c_void,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Copy slice of bytes only
|
|
|
|
/// Copy slice of bytes only
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// # Notes
|
|
|
|
/// # Notes
|
|
|
@ -9,7 +8,8 @@ pub fn copy_slice(dst: &mut [u8], src: &[u8]) -> usize
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
libc::memcpy(&mut dst[0] as *mut u8 as *mut c_void, &src[0] as *const u8 as *const c_void, sz);
|
|
|
|
//libc::memcpy(&mut dst[0] as *mut u8 as *mut c_void, &src[0] as *const u8 as *const c_void, sz);
|
|
|
|
|
|
|
|
ptr::copy_nonoverlapping(&src[0] as *const u8, &mut dst[0] as *mut u8, sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sz
|
|
|
|
sz
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -22,7 +22,8 @@ pub fn move_slice(dst: &mut [u8], src: &[u8]) -> usize
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
libc::memmove(&mut dst[0] as *mut u8 as *mut c_void, &src[0] as *const u8 as *const c_void, sz);
|
|
|
|
//libc::memmove(&mut dst[0] as *mut u8 as *mut c_void, &src[0] as *const u8 as *const c_void, sz);
|
|
|
|
|
|
|
|
ptr::copy(&src[0] as *const u8, &mut dst[0] as *mut u8, sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sz
|
|
|
|
sz
|
|
|
|
}
|
|
|
|
}
|
|
|
|