aboutsummaryrefslogtreecommitdiffstats
path: root/components/allocator/lib.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-03-13 11:44:59 +0100
committerGitHub <noreply@github.com>2024-03-13 10:44:59 +0000
commit38db1a5ce91c0fe3206bcf6e8e0c0e4a92b11138 (patch)
treef780d9d116a0dace98db8599ad52394afcaeea94 /components/allocator/lib.rs
parent0860deba05956babf77a6acd26ff9cf41431c3f1 (diff)
downloadservo-38db1a5ce91c0fe3206bcf6e8e0c0e4a92b11138.tar.gz
servo-38db1a5ce91c0fe3206bcf6e8e0c0e4a92b11138.zip
rustdoc: Add some basic Safety sections to unsafe functions (#31639)
Diffstat (limited to 'components/allocator/lib.rs')
-rw-r--r--components/allocator/lib.rs12
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();