From be1134c63b33d11c7192d4b43b2b74ae11af60ac Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Fri, 19 Apr 2024 14:29:08 +0200 Subject: [PATCH] perf(alloc): forward `realloc` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martin Kröning Signed-off-by: Martin Kröning --- src/mm/allocator.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mm/allocator.rs b/src/mm/allocator.rs index 04f78b4872..cf77a5374b 100644 --- a/src/mm/allocator.rs +++ b/src/mm/allocator.rs @@ -50,6 +50,12 @@ unsafe impl GlobalAlloc for LockedAllocator { let layout = Self::align_layout(layout); unsafe { self.0.alloc_zeroed(layout) } } + + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + let layout = Self::align_layout(layout); + let new_size = new_size.align_up(core::mem::size_of::>()); + unsafe { self.0.realloc(ptr, layout, new_size) } + } } #[cfg(all(test, not(target_os = "none")))]