30#ifndef __BASE_FREE_LIST_HH__
31#define __BASE_FREE_LIST_HH__
78 return !
precedes(o) && !o.precedes(*
this);
104 auto it = std::lower_bound(
106 [] (
const Range& range, T
base) ->
bool {
107 return range.base < base;
112 "free list: double free!\n");
115 "free list: double free!\n");
119 auto prev = std::prev(it);
120 assert(prev->base + prev->size <=
base);
121 if (prev->base + prev->size ==
base) {
154 T best_size = std::numeric_limits<T>::max();
158 best_size = it->size;
168 assert(best_it !=
_ranges.end());
169 const T
base = best_it->base;
170 best_it->base +=
size;
171 best_it->size -=
size;
172 if (best_it->size == 0)
const RangeList & ranges() const
Return a list of free ranges.
std::list< Range > RangeList
void insert(T base, T size)
Mark the range [base, base + size) as free.
std::optional< T > allocate(T size)
Allocate a region of size.
T size() const
Return the number of free items.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 Arm Limited All rights reserved.
bool overlaps(const Range &o) const
bool precedes(const Range &o) const
std::list< TranslationGen::Range > RangeList