Skip to main content

Slab

Struct Slab 

Source
#[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

Source

pub fn flags(&self) -> SlabFlags

Source

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
VersionOffset
PS4 11.000x141FE0

Trait Implementations§

Source§

impl Drop for Slab

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl RefCnt for Slab

Source§

fn increase_ref(&self)

Increments the strong reference count on the memory. Read more
Source§

fn decrease_ref(&self) -> usize

Decrements the strong reference count on the memory and returns number of references before the decreasement.
Source§

impl Send for Slab

Source§

impl Sync for Slab

Auto Trait Implementations§

§

impl !Freeze for Slab

§

impl !RefUnwindSafe for Slab

§

impl !Sized for Slab

§

impl !Unpin for Slab

§

impl !UnsafeUnpin for Slab

§

impl !UnwindSafe for Slab

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more