From 27a2b006cdbfb05457b8cc3c478c11ec03779146 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Vella Date: Tue, 21 Nov 2023 11:00:51 +0000 Subject: [PATCH] Providing alloc_zeroed instead of using default implementation. This may save some cycles of zeroing already zeroed memory. --- riscv/runtime/src/allocator.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/riscv/runtime/src/allocator.rs b/riscv/runtime/src/allocator.rs index 7fd933c8a..8828ab729 100644 --- a/riscv/runtime/src/allocator.rs +++ b/riscv/runtime/src/allocator.rs @@ -27,6 +27,10 @@ impl FixedMemoryAllocator { unsafe impl GlobalAlloc for FixedMemoryAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + self.alloc_zeroed(layout) + } + + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { // Start address of the allocation array: let array_start = addr_of!(self.mem_buffer) as usize;