Struct mnemos_alloc::node::Active
source · #[repr(C)]pub(crate) struct Active<T> {
heap: *const AHeap,
data: T,
}
Expand description
An Active node type
This type represents a live allocation of a single item, similar to a
Box<T>
in liballoc.
It contains a pointer to the allocator, as well as storage for the item.
The contained data MUST be valid for the lifetime of the Active<T>
.
Fields§
§heap: *const AHeap
§data: T
Implementations§
source§impl<T> Active<T>
impl<T> Active<T>
sourcepub(crate) unsafe fn yeet(ptr: NonNull<Active<T>>)
pub(crate) unsafe fn yeet(ptr: NonNull<Active<T>>)
Convert an Active<T>
into a Recycle
, and release it to be freed
This function does NOT handle dropping of the contained T, which must be done BEFORE calling this function.
fn data_offset() -> isize
pub(crate) unsafe fn from_leaked_ptr(data: NonNull<T>) -> NonNull<Active<T>>
sourcepub(crate) unsafe fn write_heap(this: NonNull<Active<T>>, heap: *const AHeap)
pub(crate) unsafe fn write_heap(this: NonNull<Active<T>>, heap: *const AHeap)
Set the heap pointer contained within the given Active<T>
.
This should ONLY be used to initialize the Active<T>
at time of allocation.
sourcepub(crate) unsafe fn data(this: NonNull<Active<T>>) -> NonNull<T>
pub(crate) unsafe fn data(this: NonNull<Active<T>>) -> NonNull<T>
Obtain a pointer to the underlying data storage
Although Active<T>
does not have the same provenance challenges that the
ActiveArr<T>
type has, we use the same data
interface for reasons of
consistency. This also ensures that reordering or other modifications of
the underlying node type do not require changes elsewhere.