aboutsummaryrefslogtreecommitdiffstats
path: root/components/allocator/lib.rs
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-02-29 09:43:03 +0100
committerGitHub <noreply@github.com>2024-02-29 08:43:03 +0000
commit9a9abe9152fb3691d9ff97e743bb46c1c4ebea8c (patch)
tree104376867fd202586be934a217f4d0f90ea7e72c /components/allocator/lib.rs
parentcd92a17c5e1b6c7e2cb48ae83021f78a668343e2 (diff)
downloadservo-9a9abe9152fb3691d9ff97e743bb46c1c4ebea8c.tar.gz
servo-9a9abe9152fb3691d9ff97e743bb46c1c4ebea8c.zip
Add `use-system-allocator` to not use jemalloc (#31443)
* Add `use-system-allocator` feature * Allow `servo_allocator/use-system-allocator` on servoshell
Diffstat (limited to 'components/allocator/lib.rs')
-rw-r--r--components/allocator/lib.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs
index 9d7c0b466f0..f6cf47eada5 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(any(windows, target_os = "android")))]
+#[cfg(not(any(windows, target_os = "android", feature = "use-system-allocator")))]
mod platform {
use std::os::raw::c_void;
@@ -28,14 +28,21 @@ mod platform {
}
}
-#[cfg(target_os = "android")]
+#[cfg(all(
+ not(windows),
+ any(target_os = "android", feature = "use-system-allocator")
+))]
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)
+ #[cfg(target_os = "linux")]
+ return libc::malloc_usable_size(ptr as *mut _);
+
+ #[cfg(not(target_os = "linux"))]
+ return libc::malloc_usable_size(ptr);
}
pub mod libc_compat {