use std::alloc::{AllocError, Allocator, Layout};
use std::ptr::NonNull;
use std::sync::Mutex;
pub struct HugeSingletonAllocator {
memory: Mutex<*mut u8>,
}
impl HugeSingletonAllocator {
pub fn new() -> Self {
Self {
memory: Mutex::new(std::ptr::null_mut()),
}
}
}
unsafe impl Allocator for HugeSingletonAllocator {
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
let p = *self.memory.lock().unwrap();
if p == std::ptr::null_mut() {
std::ffi::mm
} else {
Err(AllocError)
}
}
unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {
}
}