StuBS
Loading...
Searching...
No Matches
Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List Struct Reference

Free List structure Free lists are stored as circular doubly-linked lists. Every possible allocation size has an associated free list that is threaded through all currently free blocks of that size. That means MIN_ALLOC must be at least "sizeof(List)". More...

Collaboration diagram for Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List:

Public Member Functions

void clear ()
 Clear the list Because these are circular lists, an "empty" list is an entry where both links point to itself. This makes insertion and removal simpler because they don't need any branches.
 
void push (List *entry)
 Append the provided entry to the end of the list. This assumes the entry isn't in a list already because it overwrites the linked list pointers.
 
Listremove ()
 Remove the provided entry from whichever list it's currently in. This assumes that the entry is in a list. You don't need to provide the list because the lists are circular, so the list's pointers will automatically be updated if the first or last entries are removed.
 
Listpop ()
 Remove and return the first entry in the list.
 

Public Attributes

Listprev
 Pointer to previous item (or this if first)
 
Listnext
 Pointer to next item (or this if last)
 

Detailed Description

template<size_t MIN_ALLOC_LOG2, size_t MAX_ALLOC_LOG2, size_t BLOCK_SIZE, void *(*)(void *, size_t) RESERVE>
struct Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List

Free List structure Free lists are stored as circular doubly-linked lists. Every possible allocation size has an associated free list that is threaded through all currently free blocks of that size. That means MIN_ALLOC must be at least "sizeof(List)".

Member Function Documentation

◆ pop()

template<size_t MIN_ALLOC_LOG2, size_t MAX_ALLOC_LOG2, size_t BLOCK_SIZE, void *(*)(void *, size_t) RESERVE>
List * Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List::pop ( )
inline

Remove and return the first entry in the list.

Returns
the first entry or nullptr if the list is empty.

◆ push()

template<size_t MIN_ALLOC_LOG2, size_t MAX_ALLOC_LOG2, size_t BLOCK_SIZE, void *(*)(void *, size_t) RESERVE>
void Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List::push ( List * entry)
inline

Append the provided entry to the end of the list. This assumes the entry isn't in a list already because it overwrites the linked list pointers.

Parameters
entrynew list entry

◆ remove()

template<size_t MIN_ALLOC_LOG2, size_t MAX_ALLOC_LOG2, size_t BLOCK_SIZE, void *(*)(void *, size_t) RESERVE>
List * Allocator::Buddy< MIN_ALLOC_LOG2, MAX_ALLOC_LOG2, BLOCK_SIZE, RESERVE >::List::remove ( )
inline

Remove the provided entry from whichever list it's currently in. This assumes that the entry is in a list. You don't need to provide the list because the lists are circular, so the list's pointers will automatically be updated if the first or last entries are removed.

Returns
pointer to the element

The documentation for this struct was generated from the following file: