12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #![allow(unused_features)]
- #![cfg_attr(feature = "unstable", feature(const_mut_refs))]
- #![no_std]
- #![crate_name = "slabmalloc"]
- #![crate_type = "lib"]
- #![feature(new_uninit)]
- #![feature(maybe_uninit_as_bytes)]
- extern crate alloc;
- mod pages;
- mod sc;
- mod zone;
- pub use pages::*;
- pub use sc::*;
- pub use zone::*;
- use core::alloc::Layout;
- use core::fmt;
- use core::ptr::{self, NonNull};
- use log::trace;
- const OBJECT_PAGE_METADATA_OVERHEAD: usize = 80;
- const OBJECT_PAGE_SIZE: usize = 4096;
- type VAddr = usize;
- #[derive(Debug)]
- pub enum AllocationError {
-
-
- OutOfMemory,
-
- InvalidLayout,
- }
- pub unsafe trait Allocator<'a> {
- fn allocate(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocationError>;
- fn deallocate(&mut self, ptr: NonNull<u8>, layout: Layout) -> Result<(), AllocationError>;
-
-
-
-
- unsafe fn refill(
- &mut self,
- layout: Layout,
- new_page: &'a mut ObjectPage<'a>,
- ) -> Result<(), AllocationError>;
- }
|