| 192 | } |
| 193 | |
| 194 | ClassId MemoryPool::getAllocationClassId(uint32_t size) const { |
| 195 | if (size > acSizes_.back() || size == 0) { |
| 196 | throw std::invalid_argument( |
| 197 | fmt::format("Invalid size for alloc {} ", size)); |
| 198 | } |
| 199 | |
| 200 | // can operate without holding the mutex since the vector does not change. |
| 201 | const auto it = std::lower_bound(acSizes_.begin(), acSizes_.end(), size); |
| 202 | |
| 203 | // we already checked for the bounds. |
| 204 | XDCHECK(it != acSizes_.end()); |
| 205 | |
| 206 | const auto idx = std::distance(acSizes_.begin(), it); |
| 207 | XDCHECK_LT(static_cast<size_t>(idx), ac_.size()); |
| 208 | return static_cast<ClassId>(idx); |
| 209 | } |
| 210 | |
| 211 | ClassId MemoryPool::getAllocationClassId(const void* memory) const { |
| 212 | // find the slab for this allocation and the header for the slab. None of |