• Home
  • Raw
  • Download

Lines Matching +full:non +full:- +full:safety

1 // SPDX-License-Identifier: Apache-2.0 OR MIT
26 …// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to opt…
30 fn __rust_alloc(size: usize, align: usize) -> *mut u8; in __rust_alloc()
36 fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8; in __rust_realloc()
39 fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8; in __rust_alloc_zeroed()
69 /// # Safety
94 pub unsafe fn alloc(layout: Layout) -> *mut u8 { in alloc()
113 /// # Safety
131 /// # Safety
137 pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { in realloc()
141 /// Allocate zero-initialized memory with the global allocator.
150 /// # Safety
171 pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { in alloc_zeroed()
178 fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> { in alloc_impl()
181 // SAFETY: `layout` is non-zero in size, in alloc_impl()
190 // SAFETY: Same as `Allocator::grow`
198 ) -> Result<NonNull<[u8]>, AllocError> { in grow_impl()
207 // SAFETY: `new_size` is non-zero as `old_size` is greater than or equal to `new_size` in grow_impl()
208 // as required by safety conditions. Other conditions must be upheld by the caller in grow_impl()
218 raw_ptr.add(old_size).write_bytes(0, new_size - old_size); in grow_impl()
223 // SAFETY: because `new_layout.size()` must be greater than or equal to `old_size`, in grow_impl()
226 // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract in grow_impl()
242 fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { in allocate()
247 fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { in allocate_zeroed()
254 // SAFETY: `layout` is non-zero in size, in deallocate()
266 ) -> Result<NonNull<[u8]>, AllocError> { in grow()
267 // SAFETY: all conditions must be upheld by the caller in grow()
277 ) -> Result<NonNull<[u8]>, AllocError> { in grow_zeroed()
278 // SAFETY: all conditions must be upheld by the caller in grow_zeroed()
288 ) -> Result<NonNull<[u8]>, AllocError> { in shrink()
295 // SAFETY: conditions must be upheld by the caller in shrink()
301 // SAFETY: `new_size` is non-zero. Other conditions must be upheld by the caller in shrink()
311 // SAFETY: because `new_size` must be smaller than or equal to `old_layout.size()`, in shrink()
314 // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract in shrink()
330 unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { in exchange_malloc()
345 fn __rust_alloc_error_handler(size: usize, align: usize) -> !; in __rust_alloc_error_handler()
364 pub const fn handle_alloc_error(layout: Layout) -> ! { in handle_alloc_error()
365 const fn ct_error(_: Layout) -> ! { in handle_alloc_error()
369 fn rt_error(layout: Layout) -> ! { in handle_alloc_error()
390 pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! { in __rdl_oom()
393 // Its value depends on the -Zoom={panic,abort} compiler option. in __rdl_oom()
407 /// Specialize clones into pre-allocated, uninitialized memory.
417 // the cloned value in-place, skipping the local and move. in write_clone_into_raw()
425 // We can always copy in-place, without ever involving a local value. in write_clone_into_raw()