Create an allocator module with a dummy allocator

This commit is contained in:
Philipp Oppermann
2019-06-17 17:49:06 +02:00
parent 48e2175bac
commit c0367074ac
2 changed files with 15 additions and 0 deletions

14
src/allocator.rs Normal file
View File

@@ -0,0 +1,14 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
pub struct Dummy;
unsafe impl GlobalAlloc for Dummy {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View File

@@ -9,6 +9,7 @@ extern crate alloc;
use core::panic::PanicInfo; use core::panic::PanicInfo;
pub mod allocator;
pub mod gdt; pub mod gdt;
pub mod interrupts; pub mod interrupts;
pub mod memory; pub mod memory;