diff options
| author | maekawatoshiki <konndennsa@gmail.com> | 2020-08-21 14:14:58 +0900 |
|---|---|---|
| committer | maekawatoshiki <konndennsa@gmail.com> | 2020-08-21 14:14:58 +0900 |
| commit | 3a46cca4aeb2f5c0dcbc9e982d915c519c44f783 (patch) | |
| tree | 24e5dc86c3a427f5a0e44c81379cef5de214e7c3 /library/std/src/sys/hermit/alloc.rs | |
| parent | 7cae9e8c88e468e94c157d9aaee4b8e3cf90b9a4 (diff) | |
| download | rust-3a46cca4aeb2f5c0dcbc9e982d915c519c44f783.tar.gz rust-3a46cca4aeb2f5c0dcbc9e982d915c519c44f783.zip | |
Revert "`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit"
This reverts commit 7cae9e8c88e468e94c157d9aaee4b8e3cf90b9a4.
Diffstat (limited to 'library/std/src/sys/hermit/alloc.rs')
| -rw-r--r-- | library/std/src/sys/hermit/alloc.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/library/std/src/sys/hermit/alloc.rs b/library/std/src/sys/hermit/alloc.rs index 04446172197..d153914e77e 100644 --- a/library/std/src/sys/hermit/alloc.rs +++ b/library/std/src/sys/hermit/alloc.rs @@ -1,5 +1,3 @@ -#![deny(unsafe_op_in_unsafe_fn)] - use crate::alloc::{GlobalAlloc, Layout, System}; use crate::ptr; use crate::sys::hermit::abi; @@ -8,33 +6,26 @@ use crate::sys::hermit::abi; unsafe impl GlobalAlloc for System { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - // SAFETY: The safety contract for `malloc` must be upheld by the caller. - unsafe { abi::malloc(layout.size(), layout.align()) } + abi::malloc(layout.size(), layout.align()) } unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { - // SAFETY: The safety contract for `malloc` must be upheld by the caller. - // Also, `addr` must be valid for writes of `layout.size() * size_of::<u8>()` bytes. - unsafe { - let addr = abi::malloc(layout.size(), layout.align()); - - if !addr.is_null() { - ptr::write_bytes(addr, 0x00, layout.size()); - } + let addr = abi::malloc(layout.size(), layout.align()); - addr + if !addr.is_null() { + ptr::write_bytes(addr, 0x00, layout.size()); } + + addr } #[inline] unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - // SAFETY: The safety contract for `free` must be upheld by the caller. - unsafe { abi::free(ptr, layout.size(), layout.align()) } + abi::free(ptr, layout.size(), layout.align()) } #[inline] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { - // SAFETY: The safety contract for `realloc` must be upheld by the caller. - unsafe { abi::realloc(ptr, layout.size(), layout.align(), new_size) } + abi::realloc(ptr, layout.size(), layout.align(), new_size) } } |
