Move #[global_allocator] into allocator module (#714)

The Rust issue that the #[global_allocator] cannot be defined in submodules was fixed.
This commit is contained in:
Philipp Oppermann
2020-01-08 12:38:06 +01:00
committed by GitHub
parent 817267e51c
commit 869a69e531
2 changed files with 5 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
use linked_list_allocator::LockedHeap;
use x86_64::{
structures::paging::{
mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
@@ -10,6 +11,9 @@ use x86_64::{
pub const HEAP_START: usize = 0x_4444_4444_0000;
pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
pub fn init_heap(
mapper: &mut impl Mapper<Size4KiB>,
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
@@ -31,7 +35,7 @@ pub fn init_heap(
}
unsafe {
super::ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE);
ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE);
}
Ok(())