Struct catalyst_entities::Allocator
source · pub struct Allocator { /* private fields */ }Expand description
A simple bump allocator that allocates memory into fixed size chunks.
Implementations§
source§impl Allocator
impl Allocator
sourcepub const DEFAULT_CHUNK_SIZE: usize = 2_097_152usize
pub const DEFAULT_CHUNK_SIZE: usize = 2_097_152usize
Something with linux page size
sourcepub fn new(chunk_size: usize) -> Self
pub fn new(chunk_size: usize) -> Self
Create a new allocator with a chunk size of chunk_size.
The constructor by it self does not allocate anything.
sourcepub fn alloc(&mut self, layout: Layout, write_padding: bool) -> NonNull<[u8]>
pub fn alloc(&mut self, layout: Layout, write_padding: bool) -> NonNull<[u8]>
Allocate a new chunk of memory. This rarely causes system calls if the layout size is small compared to the chunk size. Lifetime of the returned memory is tied to the lifetime of the allocator.
sourcepub unsafe fn clear(&mut self)
pub unsafe fn clear(&mut self)
Declares all memory freed. Using the pointers after this call is UB.
sourcepub fn frame(&mut self) -> AllocatorFrame<'_>
pub fn frame(&mut self) -> AllocatorFrame<'_>
Creates allocator frame, frame takes snapshot of the allocator and frees subsequent allocations on drop.
Trait Implementations§
Auto Trait Implementations§
impl !ArchiveCopy for Allocator
impl NoInteriorMutability for Allocator
impl RefUnwindSafe for Allocator
impl !Send for Allocator
impl !Sync for Allocator
impl Unpin for Allocator
impl UnwindSafe for Allocator
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.