Struct FirstFitAllocatorBase::Memory
Defined in File first_fit_allocator_base.hpp
This struct is a nested type of Class FirstFitAllocatorBase.
-
struct Memory
Helper data structure for efficient memory block searching.
Represents a node in a binary segment tree used to track free and allocated memory regions.
Public Functions
-
void update(const Memory &left_child, const Memory &right_child)
Update this node using information from both children.
Updates the node’s properties based on its left and right children:
size = left.size + right.size
left = left.left or left.size + right.left iff left.max == left.size
right = right.right or right.right + left.right iff right.max == right.size
max = max(left.max, right.max, left.right + right.left)
- Parameters
left_child – Left child node.
right_child – Right child node.
-
void set(int32_t free)
Mark a node as free or allocated.
- Parameters
free – 1 if the node should be marked as free, 0 if allocated.
Public Members
-
int32_t left
Size of available memory starting from the left side of the subtree.
-
int32_t right
Size of available memory starting from the right side of the subtree.
-
int32_t max
Size of the largest available block in the subtree. Contains -1 when a block starts at this index.
-
int32_t size
Constant size of the subtree. When a block is acquired, contains the size that was acquired.
-
void update(const Memory &left_child, const Memory &right_child)