Skip to content

Commit 157ef80

Browse files
Merge pull request #132 from ryancinsight/master
remove libc usage
2 parents bb3223c + d1f55f6 commit 157ef80

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

snmalloc-sys/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ build = "build.rs"
1616
cc = {version = "1.0",optional=true}
1717
cmake = {version = "0.1",optional=true}
1818

19-
20-
[dependencies.libc]
21-
version = "0.2"
22-
default-features = false
23-
2419
[features]
2520
default = ["1mib","build_cmake"]
2621
build_cc = ["cc"]

snmalloc-sys/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#![no_std]
22
#![allow(non_camel_case_types)]
33

4-
use core::ffi::c_void;
5-
use libc::size_t;
4+
use {core::ffi::c_void, core::usize};
65

76
extern "C" {
87
/// Allocate the memory with the given alignment and size.
@@ -12,14 +11,14 @@ extern "C" {
1211
/// - `alignment` is greater than zero
1312
/// - `alignment` is a power of 2
1413
/// The program may be forced to abort if the constrains are not full-filled.
15-
pub fn rust_alloc(alignment: size_t, size: size_t) -> *mut c_void;
14+
pub fn rust_alloc(alignment: usize, size: usize) -> *mut c_void;
1615

1716
/// De-allocate the memory at the given address with the given alignment and size.
1817
/// The client must assure the following things:
1918
/// - the memory is acquired using the same allocator and the pointer points to the start position.
2019
/// - `alignment` and `size` is the same as allocation
2120
/// The program may be forced to abort if the constrains are not full-filled.
22-
pub fn rust_dealloc(ptr: *mut c_void, alignment: size_t, size: size_t) -> c_void;
21+
pub fn rust_dealloc(ptr: *mut c_void, alignment: usize, size: usize) -> c_void;
2322

2423
/// Re-allocate the memory at the given address with the given alignment and size.
2524
/// On success, it returns a pointer pointing to the required memory address.
@@ -32,9 +31,9 @@ extern "C" {
3231
/// The program may be forced to abort if the constrains are not full-filled.
3332
pub fn rust_realloc(
3433
ptr: *mut c_void,
35-
alignment: size_t,
36-
old_size: size_t,
37-
new_size: size_t,
34+
alignment: usize,
35+
old_size: usize,
36+
new_size: usize,
3837
) -> *mut c_void;
3938

4039
/// Allocate `count` items of `size` length each.

0 commit comments

Comments
 (0)