Grow table with initialization value.
| 70 | |
| 71 | /// Grow table with initialization value. |
| 72 | bool growTable(const uint64_t Count, const RefVariant &Val) noexcept { |
| 73 | if (Count == 0) { |
| 74 | return true; |
| 75 | } |
| 76 | uint64_t MaxSizeCaped = getMaxAddress(TabType.getLimit().getAddrType()); |
| 77 | const uint64_t Min = TabType.getLimit().getMin(); |
| 78 | assuming(MaxSizeCaped >= Min); |
| 79 | if (TabType.getLimit().hasMax()) { |
| 80 | const uint64_t Max = TabType.getLimit().getMax(); |
| 81 | MaxSizeCaped = std::min(Max, MaxSizeCaped); |
| 82 | } |
| 83 | if (Count > MaxSizeCaped - Min) { |
| 84 | return false; |
| 85 | } |
| 86 | Refs.resize(Refs.size() + Count); |
| 87 | std::fill_n(Refs.end() - static_cast<std::ptrdiff_t>(Count), Count, Val); |
| 88 | TabType.getLimit().setMin(Min + Count); |
| 89 | return true; |
| 90 | } |
| 91 | bool growTable(const uint64_t Count) noexcept { |
| 92 | return growTable(Count, InitValue); |
| 93 | } |
no test coverage detected