#[repr(C)]pub struct Slab {
pub(super) pin: PhantomPinned,
pub(super) hdr: SlabHdr,
pub(super) free: [u8],
}Expand description
Implementation of uma_slab.
Unlike Orbis, we don’t support uma_slab_refcnt. We use alloc::sync::Arc for that job instead
so you need to wrap the item to allocate from the slab with alloc::sync::Arc for any zones
that going to create with UMA_ZONE_REFCNT.
We use slightly different mechanism here but has the same memory layout (except we don’t support
uma_slab_refcnt as stated on the above).
§Safety
Adding more fields into this struct without knowing how it work can cause undefined behavior in some places.
Fields§
§pin: PhantomPinned§hdr: SlabHdr§free: [u8]Implementations§
Source§impl Slab
impl Slab
pub fn flags(&self) -> SlabFlags
Sourcepub fn alloc_item(&self) -> *mut u8
pub fn alloc_item(&self) -> *mut u8
Each allocated item keep a strong reference to the slab, which mean all allocated item need to free manually otherwise the slab (and its keg) will be leak.
Unlike Orbis, this method will return null if the slab already full instead of trigger a UB.
See slab_alloc_item on the Orbis for a reference.
§Reference offsets
| Version | Offset |
|---|---|
| PS4 11.00 | 0x141FE0 |