|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
use libc::{
|
|
|
|
|
c_void,
|
|
|
|
|
};
|
|
|
|
|
use std::ptr;
|
|
|
|
|
|
|
|
|
|
/// Copy slice of bytes only
|
|
|
|
|
///
|
|
|
|
|
/// # Notes
|
|
|
|
@ -9,7 +8,8 @@ pub fn copy_slice(dst: &mut [u8], src: &[u8]) -> usize
|
|
|
|
|
{
|
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
@ -22,7 +22,8 @@ pub fn move_slice(dst: &mut [u8], src: &[u8]) -> usize
|
|
|
|
|
{
|
|
|
|
|
let sz = std::cmp::min(dst.len(),src.len());
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|