From c0367074ac143c8952c7fdd7150b470ec9ad5739 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 17 Jun 2019 17:49:06 +0200 Subject: [PATCH] Create an allocator module with a dummy allocator --- src/allocator.rs | 14 ++++++++++++++ src/lib.rs | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/allocator.rs diff --git a/src/allocator.rs b/src/allocator.rs new file mode 100644 index 00000000..ac452c10 --- /dev/null +++ b/src/allocator.rs @@ -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") + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index d27b7b49..320a3ca4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ extern crate alloc; use core::panic::PanicInfo; +pub mod allocator; pub mod gdt; pub mod interrupts; pub mod memory;