const BUDDY_MAX_ORDER
pub const BUDDY_MAX_ORDER = 10Purpose
Constant BUDDY_MAX_ORDER, defining protocol or algorithm parameters.
#core/allocStandard library package `#core/alloc`.
const BUDDY_MAX_ORDERpub const BUDDY_MAX_ORDER = 10Constant BUDDY_MAX_ORDER, defining protocol or algorithm parameters.
struct Layoutpub struct Layout {
pub size int
pub align int
}Structure encapsulating size, align.
size intalign intlayout_newpub fn layout_new(size int, align int) LayoutLayout new.
size intalign intLayout — a value of this type
struct@ GlobalAllocpub struct@ GlobalAlloc {
fn alloc(Layout) *raw u8
fn dealloc(*raw u8, Layout)
}Method-set constraint GlobalAlloc.
alloc fn alloc(Layout) *raw u8alloc on GlobalAlloc.dealloc fn dealloc(*raw u8, Layout)dealloc on GlobalAlloc.(GlobalAlloc) allocfn alloc(Layout) *raw u8Execute alloc on GlobalAlloc.
self SelfSelf instance used by this call (value receiver).layout Layout*raw u8 — a value of this type
(GlobalAlloc) deallocfn dealloc(*raw u8, Layout)Execute dealloc on GlobalAlloc.
self SelfSelf instance used by this call (value receiver).v *raw u8layout LayoutThis call does not return a value.
is_power_of_twopub fn is_power_of_two(n usize) boolWhether it is power of two.
n usizebool — true or false
align_uppub fn align_up(addr usize, align usize) usizeAlign up.
addr usizealign usizeusize — a value of this type
align_downpub fn align_down(addr usize, align usize) usizeAlign down.
addr usizealign usizeusize — a value of this type
(Layout) byte_sizepub fn (l Layout) byte_size() usizeOperation on Layout: byte size.
l LayoutLayout instance used by this call (value receiver).usize — a value of this type
(Layout) byte_alignpub fn (l Layout) byte_align() usizeOperation on Layout: byte align.
l LayoutLayout instance used by this call (value receiver).usize — a value of this type
(Layout) is_validpub fn (l Layout) is_valid() boolOperation on Layout: whether it is valid.
l LayoutLayout instance used by this call (value receiver).bool — true or false
struct BumpAllocatorpub struct BumpAllocator {
pub base usize
pub limit usize
pub cursor usize
pub allocs usize
}Structure encapsulating base, limit, cursor, allocs.
base usizelimit usizecursor usizeallocs usizebump_initpub fn bump_init(a *raw BumpAllocator, base *raw u8, size usize)Bump init.
a *raw BumpAllocatorbase *raw u8size usizeThis call does not return a value.
($&BumpAllocator) alloc_rawpub fn (a $&BumpAllocator) alloc_raw(size usize, align usize) *raw u8Operation on $&BumpAllocator: alloc raw.
a $&BumpAllocatorBumpAllocator instance used by this call (exclusive borrow).size usizealign usize*raw u8 — a value of this type
($&BumpAllocator) alloc_zeroedpub fn (a $&BumpAllocator) alloc_zeroed(size usize, align usize) *raw u8Operation on $&BumpAllocator: alloc zeroed.
a $&BumpAllocatorBumpAllocator instance used by this call (exclusive borrow).size usizealign usize*raw u8 — a value of this type
($&BumpAllocator) allocpub fn (a $&BumpAllocator) alloc(layout Layout) *raw u8Execute alloc on $&BumpAllocator.
a $&BumpAllocatorBumpAllocator instance used by this call (exclusive borrow).layout Layout*raw u8 — a value of this type
($&BumpAllocator) deallocpub fn (a $&BumpAllocator) dealloc(ptr *raw u8, layout Layout)Execute dealloc on $&BumpAllocator.
a $&BumpAllocatorBumpAllocator instance used by this call (exclusive borrow).ptr *raw u8layout LayoutThis call does not return a value.
($&BumpAllocator) resetpub fn (a $&BumpAllocator) reset()Operation on $&BumpAllocator: clear internal state so the value can be reused.
a $&BumpAllocatorBumpAllocator instance used by this call (exclusive borrow).This call does not return a value.
(&BumpAllocator) usedpub fn (a &BumpAllocator) used() usizeExecute used on &BumpAllocator.
a &BumpAllocatorBumpAllocator instance used by this call (borrow).usize — a value of this type
(&BumpAllocator) remainingpub fn (a &BumpAllocator) remaining() usizeExecute remaining on &BumpAllocator.
a &BumpAllocatorBumpAllocator instance used by this call (borrow).usize — a value of this type
struct FixedPoolAllocatorpub struct FixedPoolAllocator {
pub base usize
pub end usize
pub slot_size usize
pub capacity usize
pub free_head usize
pub free_count usize
}Structure encapsulating base, end, slot_size, capacity, free_head.
base usizeend usizeslot_size usizecapacity usizefree_head usizefree_count usizefixed_pool_initpub fn fixed_pool_init(p *raw FixedPoolAllocator, mem_base *raw u8, mem_bytes usize, slot_size usize, slot_align usize) usizeFixed pool init.
p *raw FixedPoolAllocatormem_base *raw u8mem_bytes usizeslot_size usizeslot_align usizeusize — a value of this type
($&FixedPoolAllocator) alloc_slotpub fn (p $&FixedPoolAllocator) alloc_slot() *raw u8Operation on $&FixedPoolAllocator: alloc slot.
p $&FixedPoolAllocatorFixedPoolAllocator instance used by this call (exclusive borrow).*raw u8 — a value of this type
($&FixedPoolAllocator) free_slotpub fn (p $&FixedPoolAllocator) free_slot(ptr *raw u8) boolOperation on $&FixedPoolAllocator: free slot.
p $&FixedPoolAllocatorFixedPoolAllocator instance used by this call (exclusive borrow).ptr *raw u8bool — true or false
(&FixedPoolAllocator) availablepub fn (p &FixedPoolAllocator) available() usizeExecute available on &FixedPoolAllocator.
p &FixedPoolAllocatorFixedPoolAllocator instance used by this call (borrow).usize — a value of this type
(&FixedPoolAllocator) in_usepub fn (p &FixedPoolAllocator) in_use() usizeOperation on &FixedPoolAllocator: in use.
p &FixedPoolAllocatorFixedPoolAllocator instance used by this call (borrow).usize — a value of this type
struct LinkedListAllocatorpub struct LinkedListAllocator {
pub base usize
pub end usize
pub head usize
pub bytes_used usize
pub bytes_free usize
pub block_count usize
pub alloc_count usize
pub free_count usize
}Structure encapsulating base, end, head, bytes_used, bytes_free.
base usizeend usizehead usizebytes_used usizebytes_free usizeblock_count usizealloc_count usizefree_count usizelinked_list_initpub fn linked_list_init(a *raw LinkedListAllocator, base *raw u8, size usize) boolLinked list init.
a *raw LinkedListAllocatorbase *raw u8size usizebool — true or false
($&LinkedListAllocator) alloc_rawpub fn (a $&LinkedListAllocator) alloc_raw(size usize, align usize) *raw u8Operation on $&LinkedListAllocator: alloc raw.
a $&LinkedListAllocatorLinkedListAllocator instance used by this call (exclusive borrow).size usizealign usize*raw u8 — a value of this type
($&LinkedListAllocator) alloc_zeroedpub fn (a $&LinkedListAllocator) alloc_zeroed(size usize, align usize) *raw u8Operation on $&LinkedListAllocator: alloc zeroed.
a $&LinkedListAllocatorLinkedListAllocator instance used by this call (exclusive borrow).size usizealign usize*raw u8 — a value of this type
($&LinkedListAllocator) dealloc_rawpub fn (a $&LinkedListAllocator) dealloc_raw(ptr *raw u8) boolOperation on $&LinkedListAllocator: dealloc raw.
a $&LinkedListAllocatorLinkedListAllocator instance used by this call (exclusive borrow).ptr *raw u8bool — true or false
($&LinkedListAllocator) allocpub fn (a $&LinkedListAllocator) alloc(layout Layout) *raw u8Execute alloc on $&LinkedListAllocator.
a $&LinkedListAllocatorLinkedListAllocator instance used by this call (exclusive borrow).layout Layout*raw u8 — a value of this type
($&LinkedListAllocator) deallocpub fn (a $&LinkedListAllocator) dealloc(ptr *raw u8, layout Layout)Execute dealloc on $&LinkedListAllocator.
a $&LinkedListAllocatorLinkedListAllocator instance used by this call (exclusive borrow).ptr *raw u8layout LayoutThis call does not return a value.
(&LinkedListAllocator) usedpub fn (a &LinkedListAllocator) used() usizeExecute used on &LinkedListAllocator.
a &LinkedListAllocatorLinkedListAllocator instance used by this call (borrow).usize — a value of this type
(&LinkedListAllocator) free_bytespub fn (a &LinkedListAllocator) free_bytes() usizeOperation on &LinkedListAllocator: free bytes.
a &LinkedListAllocatorLinkedListAllocator instance used by this call (borrow).usize — a value of this type
(&LinkedListAllocator) blockspub fn (a &LinkedListAllocator) blocks() usizeExecute blocks on &LinkedListAllocator.
a &LinkedListAllocatorLinkedListAllocator instance used by this call (borrow).usize — a value of this type
(&LinkedListAllocator) allocspub fn (a &LinkedListAllocator) allocs() usizeExecute allocs on &LinkedListAllocator.
a &LinkedListAllocatorLinkedListAllocator instance used by this call (borrow).usize — a value of this type
(&LinkedListAllocator) freespub fn (a &LinkedListAllocator) frees() usizeExecute frees on &LinkedListAllocator.
a &LinkedListAllocatorLinkedListAllocator instance used by this call (borrow).usize — a value of this type
struct BuddyBlockpub struct BuddyBlock {
pub next u64
pub prev u64
}Structure encapsulating next, prev.
next u64prev u64struct BuddyAllocatorpub struct BuddyAllocator {
pub base u64
pub total_pages usize
pub free_pages usize
pub max_order int
pub pad0 u32
pub free_lists [11]u64
}Structure encapsulating base, total_pages, free_pages, max_order, pad0.
base u64total_pages usizefree_pages usizemax_order intpad0 u32free_lists [11]u64buddy_initpub fn buddy_init(b *raw BuddyAllocator, base u64, num_pages usize) boolBuddy init.
b *raw BuddyAllocatorbase u64num_pages usizebool — true or false
($&BuddyAllocator) alloc_orderpub fn (b $&BuddyAllocator) alloc_order(order int) u64Operation on $&BuddyAllocator: alloc order.
b $&BuddyAllocatorBuddyAllocator instance used by this call (exclusive borrow).order intu64 — a value of this type
($&BuddyAllocator) free_orderpub fn (b $&BuddyAllocator) free_order(addr u64, order int) boolOperation on $&BuddyAllocator: free order.
b $&BuddyAllocatorBuddyAllocator instance used by this call (exclusive borrow).addr u64order intbool — true or false
(&BuddyAllocator) free_page_countpub fn (b &BuddyAllocator) free_page_count() usizeOperation on &BuddyAllocator: free page count.
b &BuddyAllocatorBuddyAllocator instance used by this call (borrow).usize — a value of this type
struct SlabAllocatorpub struct SlabAllocator {
pub pools [8]FixedPoolAllocator
pub base u64
pub size usize
}Structure encapsulating pools, base, size.
pools [8]FixedPoolAllocatorbase u64size usizeslab_initpub fn slab_init(s *raw SlabAllocator, base *raw u8, total_bytes usize) boolSlab init.
s *raw SlabAllocatorbase *raw u8total_bytes usizebool — true or false
($&SlabAllocator) alloc_bytespub fn (s $&SlabAllocator) alloc_bytes(size usize) *raw u8Operation on $&SlabAllocator: alloc bytes.
s $&SlabAllocatorSlabAllocator instance used by this call (exclusive borrow).size usize*raw u8 — a value of this type
($&SlabAllocator) free_bytespub fn (s $&SlabAllocator) free_bytes(ptr *raw u8, size usize) boolOperation on $&SlabAllocator: free bytes.
s $&SlabAllocatorSlabAllocator instance used by this call (exclusive borrow).ptr *raw u8size usizebool — true or false