From a27518ef2fba4452d40d46a8856af52c10204c33 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Fri, 16 Jan 2026 22:03:17 +0100 Subject: [PATCH] Use unsafe blocks in malloc.h implementation --- src/header/malloc/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/header/malloc/mod.rs b/src/header/malloc/mod.rs index 54977f414b..c3a04d930b 100644 --- a/src/header/malloc/mod.rs +++ b/src/header/malloc/mod.rs @@ -2,6 +2,9 @@ //! //! Non-POSIX, see . +// TODO: set this for entire crate when possible +#![deny(unsafe_op_in_unsafe_fn)] + use crate::{ header::errno::ENOMEM, platform::{ @@ -28,7 +31,7 @@ pub unsafe extern "C" fn pvalloc(size: size_t) -> *mut c_void { match num_pages.checked_mul(page_size) { Some(alloc_size) => { - let ptr = platform::alloc_align(alloc_size, page_size); + let ptr = unsafe { platform::alloc_align(alloc_size, page_size) }; if ptr.is_null() { platform::ERRNO.set(ENOMEM); } @@ -44,5 +47,5 @@ pub unsafe extern "C" fn pvalloc(size: size_t) -> *mut c_void { /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn malloc_usable_size(ptr: *mut c_void) -> size_t { - platform::alloc_usable_size(ptr) + unsafe { platform::alloc_usable_size(ptr) } }