diff options
-rw-r--r-- | components/allocator/lib.rs | 12 | ||||
-rw-r--r-- | components/gfx/text/shaping/harfbuzz.rs | 5 | ||||
-rw-r--r-- | components/shared/canvas/webgl.rs | 5 |
3 files changed, 22 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(); diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 96d5ccc3251..74df4b5dccf 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -47,6 +47,11 @@ pub struct ShapedGlyphEntry { } impl ShapedGlyphData { + /// Create a new [`SharedGlyphData`] from the given HarfBuzz buffer. + /// + /// # Safety + /// + /// Passing an invalid buffer pointer to this function results in undefined behavior. pub unsafe fn new(buffer: *mut hb_buffer_t) -> ShapedGlyphData { let mut glyph_count = 0; let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count); diff --git a/components/shared/canvas/webgl.rs b/components/shared/canvas/webgl.rs index 31d22bb3f52..a3f68563308 100644 --- a/components/shared/canvas/webgl.rs +++ b/components/shared/canvas/webgl.rs @@ -546,6 +546,11 @@ macro_rules! define_resource_id { impl $name { #[allow(unsafe_code)] #[inline] + /// Create a new $name. + /// + /// # Safety + /// + /// Using an invalid OpenGL id may result in undefined behavior. pub unsafe fn new(id: $type) -> Self { $name(<nonzero_type!($type)>::new_unchecked(id)) } |