auto rs_start = range_tree.lower_bound(range_t{*cursor, size}, compare);
for (auto rs = rs_start; rs != range_tree.end(); ++rs) {
uint64_t offset = p2roundup(rs->start, align);
+ *cursor = offset + size;
if (offset + size <= rs->end) {
- *cursor = offset + size;
return offset;
}
if (max_search_count > 0 && ++search_count > max_search_count) {
return -1ULL;
}
}
+
if (*cursor == 0) {
// If we already started from beginning, don't bother with searching from beginning
return -1ULL;
// If we reached end, start from beginning till cursor.
for (auto rs = range_tree.begin(); rs != rs_start; ++rs) {
uint64_t offset = p2roundup(rs->start, align);
+ *cursor = offset + size;
if (offset + size <= rs->end) {
- *cursor = offset + size;
return offset;
}
if (max_search_count > 0 && ++search_count > max_search_count) {