Skip to content

Commit

Permalink
another fix try
Browse files Browse the repository at this point in the history
  • Loading branch information
koolkdev committed Mar 20, 2024
1 parent 0e9b0ad commit 90f72b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/free_blocks_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void FreeBlocksAllocator::RecreateEPTreeIfNeeded() {
return;
std::vector<FreeBlocksRangeInfo> blocks_to_delete;
// eptree is empty (aka have only initial FTreee), resize it to one eptree
for (auto& [node_level, node_it] : std::views::reverse(last.base().nodes())) {
auto nodes = last.base().nodes();
for (auto& [node_level, node_it] : std::views::reverse(nodes)) {
if (node_level->header() == &eptree.tree_header()->current_tree) {
// this is the root, reinitialize it
node_level->Init(1);
Expand Down
22 changes: 13 additions & 9 deletions src/free_blocks_allocator_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,14 @@ class PTreeIterator {
}
uint16_t node_offset = (*rparent->iterator).value;
for (auto parent = rparent.base(); parent != parents_.end(); ++parent) {
*parent = {{node_ref<ParentNodeDetails>{block_, node_offset}}};
parent->iterator = parent->node->begin();
parent_node_info new_parent{{{block_, node_offset}}};
new_parent.iterator = new_parent.node->begin();
*parent = std::move(new_parent);
node_offset = (*parent->iterator).value;
}
leaf_ = {{node_ref<LeafNodeDetails>{block_, node_offset}}};
leaf_->iterator = leaf_->node->begin();
leaf_node_info new_leaf{{{block_, node_offset}}};
new_leaf.iterator = new_leaf.node->begin();
leaf_ = std::move(new_leaf);
}
return *this;
}
Expand All @@ -823,13 +825,15 @@ class PTreeIterator {
}
uint16_t node_offset = (*--rparent->iterator).value; // TODO: by ref
for (auto parent = rparent.base(); parent != parents_.end(); ++parent) {
*parent = {{node_ref<ParentNodeDetails>{block_, node_offset}}};
parent->iterator = parent->node->end();
--parent->iterator;
parent_node_info new_parent{{{block_, node_offset}}};
new_parent.iterator = new_parent.node->end();
--new_parent.iterator;
*parent = std::move(new_parent);
node_offset = (*parent->iterator).value; // TODO: by ref
}
leaf_ = {{node_ref<LeafNodeDetails>{block_, node_offset}}};
leaf_->iterator = leaf_->node->end();
leaf_node_info new_leaf{{{block_, node_offset}}};
new_leaf.iterator = new_leaf.node->end();
leaf_ = std::move(new_leaf);
}
--leaf_->iterator;
return *this;
Expand Down

0 comments on commit 90f72b1

Please sign in to comment.