diff options
Diffstat (limited to 'components/allocator/lib.rs')
-rw-r--r-- | components/allocator/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index f8faaa080e9..20ac30e8022 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -16,6 +16,10 @@ mod platform { pub use jemallocator::Jemalloc as Allocator; /// Get the size of a heap block. + /// + /// # Safety + /// + /// Passing a non-heap allocated pointer to this function results in undefined behavior. pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { jemallocator::usable_size(ptr) } @@ -35,6 +39,10 @@ mod platform { use std::os::raw::c_void; /// Get the size of a heap block. + /// + /// # Safety + /// + /// Passing a non-heap allocated pointer to this function results in undefined behavior. pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize { #[cfg(target_vendor = "apple")] return libc::malloc_size(ptr); @@ -56,6 +64,10 @@ mod platform { use winapi::um::heapapi::{GetProcessHeap, HeapSize, HeapValidate}; /// Get the size of a heap block. + /// + /// # Safety + /// + /// Passing a non-heap allocated pointer to this function results in undefined behavior. pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize { let heap = GetProcessHeap(); |