remove direct dependancy on libc

feed
Avril 4 years ago
parent 3b4dc663fa
commit 6453392758
Signed by: flanchan
GPG Key ID: 284488987C31F630

3
Cargo.lock generated

@ -616,7 +616,7 @@ dependencies = [
[[package]]
name = "markov"
version = "0.8.1"
version = "0.8.2"
dependencies = [
"async-compression",
"bzip2-sys",
@ -624,7 +624,6 @@ dependencies = [
"futures",
"hyper",
"lazy_static",
"libc",
"log",
"markov 1.1.0",
"once_cell",

@ -1,6 +1,6 @@
[package]
name = "markov"
version = "0.8.1"
version = "0.8.2"
description = "Generate string of text from Markov chain fed by stdin"
authors = ["Avril <flanchan@cumallover.me>"]
edition = "2018"
@ -71,7 +71,6 @@ serde = {version ="1.0", features=["derive"]}
toml = "0.5.6"
async-compression = {version = "0.3.5", features=["tokio-02", "bzip2"], optional=true}
pin-project = "0.4"
libc = "0.2.79"
smallmap = "1.1.5"
lazy_static = "1.4.0"
once_cell = "1.4.1"

@ -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
}

Loading…
Cancel
Save