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

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

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

Loading…
Cancel
Save