diff --git a/alloc_kernel/src/lib.rs b/alloc_kernel/src/lib.rs index df908438dfa842ebf2d0e844eb246d8811655be8..a7dc6078731b6601a4e7ffd51057ef09b721fb1d 100644 --- a/alloc_kernel/src/lib.rs +++ b/alloc_kernel/src/lib.rs @@ -4,6 +4,7 @@ #![allocator] #![no_std] +use core::ptr; use spin::Mutex; use linked_list_allocator::Heap; @@ -25,6 +26,15 @@ pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 { } } +#[no_mangle] +pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 { + let ptr = __rust_allocate(size, align); + unsafe { + ptr::write_bytes(ptr, 0, size); + } + ptr +} + #[no_mangle] pub extern fn __rust_deallocate(ptr: *mut u8, size: usize, align: usize) { if let Some(ref mut heap) = *HEAP.lock() {