mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-09 22:54:44 +03:00
Drop libc dependency from roc_std
This commit is contained in:
parent
27d8f7b821
commit
fbc7984818
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -3454,9 +3454,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "roc_std"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roc_types"
|
||||
|
3
examples/hello-rust/platform/Cargo.lock
generated
3
examples/hello-rust/platform/Cargo.lock
generated
@ -19,6 +19,3 @@ checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714"
|
||||
[[package]]
|
||||
name = "roc_std"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -7,6 +7,3 @@ repository = "https://github.com/rtfeldman/roc"
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
description = "Rust representations of Roc data structures"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![no_std]
|
||||
use core::convert::From;
|
||||
use core::ffi::c_void;
|
||||
use core::{fmt, mem, ptr};
|
||||
use core::{fmt, mem, ptr, slice};
|
||||
|
||||
pub mod alloca;
|
||||
|
||||
@ -586,17 +586,17 @@ impl Clone for RocStr {
|
||||
let capacity_size = core::mem::size_of::<usize>();
|
||||
let copy_length = self.length + capacity_size;
|
||||
let elements = unsafe {
|
||||
let raw = roc_alloc(copy_length, core::mem::size_of::<usize>() as u32);
|
||||
let raw_ptr =
|
||||
roc_alloc(copy_length, core::mem::size_of::<usize>() as u32) as *mut usize;
|
||||
let dest_slice = slice::from_raw_parts_mut(raw_ptr, copy_length);
|
||||
let src_ptr = self.elements.offset(-(capacity_size as isize)) as *mut usize;
|
||||
let src_slice = slice::from_raw_parts(src_ptr, copy_length);
|
||||
|
||||
libc::memcpy(
|
||||
raw,
|
||||
self.elements.offset(-(capacity_size as isize)) as *mut c_void,
|
||||
copy_length,
|
||||
);
|
||||
dest_slice.copy_from_slice(src_slice);
|
||||
|
||||
*(raw as *mut usize) = self.length;
|
||||
*(raw_ptr as *mut usize) = self.length;
|
||||
|
||||
(raw as *mut u8).add(capacity_size)
|
||||
(raw_ptr as *mut u8).add(capacity_size)
|
||||
};
|
||||
|
||||
Self {
|
||||
|
Loading…
Reference in New Issue
Block a user