From 38db1a5ce91c0fe3206bcf6e8e0c0e4a92b11138 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 13 Mar 2024 11:44:59 +0100 Subject: rustdoc: Add some basic Safety sections to unsafe functions (#31639) --- components/allocator/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'components/allocator/lib.rs') 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(); -- cgit v1.2.3