mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
rustdoc: Add some basic Safety sections to unsafe functions (#31639)
This commit is contained in:
parent
0860deba05
commit
38db1a5ce9
3 changed files with 22 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue