| 350 | } |
| 351 | |
| 352 | void SuballocatorTest::AssertMemoryValid( |
| 353 | const vector<unique_ptr<Suballocation>>& allocs) { |
| 354 | for (int64_t i = 0; i < allocs.size(); ++i) { |
| 355 | const unique_ptr<Suballocation>& alloc = allocs[i]; |
| 356 | ASSERT_GE(alloc->len(), 8); |
| 357 | // Memory should be 8-byte aligned. |
| 358 | ASSERT_EQ(0, reinterpret_cast<uint64_t>(alloc->data()) % 8) << alloc->data(); |
| 359 | for (int64_t offset = 0; offset < alloc->len(); offset += 8) { |
| 360 | *reinterpret_cast<int64_t*>(alloc->data() + offset) = i; |
| 361 | } |
| 362 | } |
| 363 | for (int64_t i = 0; i < allocs.size(); ++i) { |
| 364 | const unique_ptr<Suballocation>& alloc = allocs[i]; |
| 365 | for (int64_t offset = 0; offset < alloc->len(); offset += 8) { |
| 366 | ASSERT_EQ(*reinterpret_cast<int64_t*>(alloc->data() + offset), i) |
| 367 | << i << " " << alloc->data() << " " << offset; |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | } |