Struct maskerad_memory_allocators::MemoryChunk
[−]
[src]
pub struct MemoryChunk { /* fields omitted */ }
The MemoryChunk is just a chunk of memory. It uses a RawVec to allocate bytes in a vector-like fashion.
This structure allows you allocate data of different type in the same storage, since :
The chunk knows the location of the first unused byte in its memory storage, and update it when allocation occurs or when objects in the memory chunk are dropped.
The chunk extracts, for the types implementing the Drop trait, some info about the type (its virtual table) and place it next to the object. The chunk is able to call the drop method of the object with the virtual table.
You should not use the MemoryChunk directly. The allocators manage memory chunks, use them.
Methods
impl MemoryChunk
[src]
fn new(size: usize) -> Self
[src]
Creates a new memory chunk, allocating the given number of bytes.
fn fill(&self) -> usize
[src]
Returns the index of the first unused byte in the memory storage of the chunk.
fn set_fill(&self, first_unused_byte: usize)
[src]
Set the index of the first unused byte in the memory storage of the chunk.
fn capacity(&self) -> usize
[src]
Returns the maximal number of bytes the chunk can store.
fn as_ptr(&self) -> *const u8
[src]
Returns a pointer to the start of the memory storage used by the chunk.
unsafe fn destroy(&self)
[src]
Drop all the data contained in the chunk.
unsafe fn destroy_to_marker(&self, marker: usize)
[src]
Drop the data contained in the chunk, starting from the given marker.