diff options
Diffstat (limited to 'components/allocator')
-rw-r--r-- | components/allocator/Cargo.toml | 5 | ||||
-rw-r--r-- | components/allocator/lib.rs | 17 |
2 files changed, 17 insertions, 5 deletions
diff --git a/components/allocator/Cargo.toml b/components/allocator/Cargo.toml index fccec48a5e9..645815ba1f1 100644 --- a/components/allocator/Cargo.toml +++ b/components/allocator/Cargo.toml @@ -11,8 +11,11 @@ path = "lib.rs" [features] unstable = ["kernel32-sys", "jemallocator"] +[dependencies] +libc = "0.2" # Only used when 'unstable' is disabled, but looks like Cargo cannot express that. + [target.'cfg(not(windows))'.dependencies] -jemallocator = { version = "0.1.3", optional = true } +jemallocator = { version = "0.1.4", optional = true } [target.'cfg(windows)'.dependencies] kernel32-sys = { version = "0.2.1", optional = true } diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index e832e485575..6c248f08055 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -9,9 +9,9 @@ #[cfg(feature = "unstable")] #[global_allocator] -static ALLOC: platform::Allocator = platform::Allocator; +static ALLOC: Allocator = Allocator; -pub use platform::usable_size; +pub use platform::*; #[cfg(all(feature = "unstable", not(windows)))] @@ -25,6 +25,11 @@ mod platform { pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { jemallocator::usable_size(ptr) } + + /// Memory allocation APIs compatible with libc + pub mod libc_compat { + pub use super::jemallocator::ffi::{malloc, realloc, free}; + } } #[cfg(all(feature = "unstable", windows))] @@ -57,6 +62,10 @@ mod platform { pub unsafe extern "C" fn usable_size(_ptr: *const c_void) -> usize { 0 } -} - + /// Memory allocation APIs compatible with libc + pub mod libc_compat { + extern crate libc; + pub use self::libc::{malloc, realloc, free}; + } +} |