uber simple memory stuff

This commit is contained in:
mtgmonkey 2025-03-28 21:37:24 -04:00
parent 723662b2a1
commit 87f0156c7e
5 changed files with 142 additions and 7 deletions

26
src/allocator.rs Normal file
View 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;