| 24 | namespace { |
| 25 | |
| 26 | bool ValidContiguousView(const ContiguousBatch &view) { |
| 27 | if (!view.count) return true; |
| 28 | constexpr auto kInvalidId = std::numeric_limits<uint32_t>::max(); |
| 29 | if (!view.data || !view.stride || view.first_id >= kInvalidId || |
| 30 | view.count > kInvalidId - view.first_id) |
| 31 | return false; |
| 32 | const auto max_span = std::numeric_limits<uintptr_t>::max() - |
| 33 | reinterpret_cast<uintptr_t>(view.data); |
| 34 | return view.count <= max_span / view.stride; |
| 35 | } |
| 36 | |
| 37 | const void *GetContiguousVector(const ContiguousBatch &view, uint32_t id) { |
| 38 | if (id < view.first_id || id - view.first_id >= view.count) return nullptr; |
no outgoing calls
no test coverage detected