From 11c16adcd184dd5bc98ad946ac05e942d335f0a3 Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Mon, 11 Mar 2024 08:58:32 +0100 Subject: [PATCH] Use libc::malloc_size on apple (#31602) * Use libc::malloc_size on apple * Unify malloc_usable_size under *mut _ --- components/allocator/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index 507c0e380f6..f8faaa080e9 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -36,11 +36,11 @@ mod platform { /// Get the size of a heap block. pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { - #[cfg(target_os = "linux")] - return libc::malloc_usable_size(ptr as *mut _); + #[cfg(target_vendor = "apple")] + return libc::malloc_size(ptr); - #[cfg(not(target_os = "linux"))] - return libc::malloc_usable_size(ptr); + #[cfg(not(target_vendor = "apple"))] + return libc::malloc_usable_size(ptr as *mut _); } pub mod libc_compat {