Use libc::malloc_size on apple (#31602)

* Use libc::malloc_size on apple

* Unify malloc_usable_size under *mut _
This commit is contained in:
Samson 2024-03-11 08:58:32 +01:00 committed by GitHub
parent af3583ade8
commit 11c16adcd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,11 +36,11 @@ mod platform {
/// Get the size of a heap block. /// Get the size of a heap block.
pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize {
#[cfg(target_os = "linux")] #[cfg(target_vendor = "apple")]
return libc::malloc_usable_size(ptr as *mut _); return libc::malloc_size(ptr);
#[cfg(not(target_os = "linux"))] #[cfg(not(target_vendor = "apple"))]
return libc::malloc_usable_size(ptr); return libc::malloc_usable_size(ptr as *mut _);
} }
pub mod libc_compat { pub mod libc_compat {