From 6453392758a4f3c786f0e12c84df22bb1b9e2fe3 Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 13 Oct 2020 14:06:08 +0100 Subject: [PATCH] remove direct dependancy on libc --- Cargo.lock | 3 +-- Cargo.toml | 3 +-- src/bytes.rs | 11 ++++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e7130c..c7df56f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index 58d66d9..6df6cd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 "] 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" diff --git a/src/bytes.rs b/src/bytes.rs index 06838ab..82a18ae 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -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 }