Skip to content

Commit

Permalink
fix inline arena running out of space
Browse files Browse the repository at this point in the history
  • Loading branch information
martty committed Jan 14, 2025
1 parent 285bd2e commit c43c635
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/vuk/IR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ namespace vuk {
std::byte arena[size];
std::byte* base;
std::byte* cur;
std::vector<std::unique_ptr<char[]>> large_allocs;

InlineArena() {
base = cur = arena;
Expand All @@ -982,6 +983,11 @@ namespace vuk {
}

void* ensure_space(size_t ns) {
if (ns > size) {
auto& alloc = large_allocs.emplace_back(new char[ns]);
return static_cast<void*>(alloc.get());
}

if ((size - (cur - base)) < ns) {
grow();
}
Expand Down

0 comments on commit c43c635

Please sign in to comment.