mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add use-system-allocator
to not use jemalloc (#31443)
* Add `use-system-allocator` feature * Allow `servo_allocator/use-system-allocator` on servoshell
This commit is contained in:
parent
cd92a17c5e
commit
9a9abe9152
4 changed files with 19 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue