aboutsummaryrefslogtreecommitdiffstats
path: root/components/allocator/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/allocator/lib.rs')
-rw-r--r--components/allocator/lib.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs
index d4e8c73b318..9d7c0b466f0 100644
--- a/components/allocator/lib.rs
+++ b/components/allocator/lib.rs
@@ -9,7 +9,7 @@ static ALLOC: Allocator = Allocator;
pub use crate::platform::*;
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "android")))]
mod platform {
use std::os::raw::c_void;
@@ -28,6 +28,21 @@ mod platform {
}
}
+#[cfg(target_os = "android")]
+mod platform {
+ pub use std::alloc::System as Allocator;
+ use std::os::raw::c_void;
+
+ /// Get the size of a heap block.
+ pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize {
+ libc::malloc_usable_size(ptr)
+ }
+
+ pub mod libc_compat {
+ pub use libc::{free, malloc, realloc};
+ }
+}
+
#[cfg(windows)]
mod platform {
pub use std::alloc::System as Allocator;