mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
FreeType: don’t use usable_size() as deallocation size
Instead use C-level malloc()/free() so that the size doesn’t need to be known during deallocation, since FreeType doesn’t provide it. Hopefully fixes https://github.com/servo/servo/issues/19058
This commit is contained in:
parent
1b73cf3352
commit
6319ad0124
4 changed files with 37 additions and 50 deletions
|
@ -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 }
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue