StuBS
|
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...
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. | |
List * | remove () |
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. | |
List * | pop () |
Remove and return the first entry in the list. | |
Public Attributes | |
List * | prev |
Pointer to previous item (or this if first) | |
List * | next |
Pointer to next item (or this if last) | |
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)".
|
inline |
Remove and return the first entry in the list.
|
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.
entry | new list entry |
|
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.