Add __rust_allocate_zeroed to work with newest nightly

This commit is contained in:
Jeremy Soller
2017-04-18 21:26:18 -06:00
parent d036c667a1
commit 40ff16e42d

View File

@@ -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() {