uber simple memory stuff
This commit is contained in:
parent
723662b2a1
commit
87f0156c7e
5 changed files with 142 additions and 7 deletions
26
src/allocator.rs
Normal file
26
src/allocator.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use alloc::alloc::{GlobalAlloc, Layout};
|
||||
use core::ptr::null_mut;
|
||||
|
||||
// struct Dummy :::
|
||||
pub struct Dummy;
|
||||
|
||||
unsafe impl GlobalAlloc for Dummy {
|
||||
// fn alloc :::
|
||||
// &self :param:
|
||||
// _layout: Layout :param:
|
||||
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
|
||||
null_mut()
|
||||
}
|
||||
|
||||
// fn dealloc :::
|
||||
// &self :param:
|
||||
// _ptr: *mut u8 :param:
|
||||
// _layout: Layout :param:
|
||||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
|
||||
panic!("allocator::dealloc() should never be called")
|
||||
}
|
||||
}
|
||||
|
||||
// ALLOCATOR: Dummy :::
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: Dummy = Dummy;
|
Loading…
Add table
Add a link
Reference in a new issue