| 277 | } |
| 278 | |
| 279 | static void CheckAllocatedArea(uint8_t* ptr, int64_t size, const char* context) { |
| 280 | // Check that memory wasn't clobbered at the end of the allocated area. |
| 281 | int64_t stored_size = |
| 282 | memory_pool::internal::kDebugXorSuffix ^ util::SafeLoadAs<int64_t>(ptr + size); |
| 283 | if (ARROW_PREDICT_FALSE(stored_size != size)) { |
| 284 | auto st = Status::Invalid("Wrong size on ", context, ": given size = ", size, |
| 285 | ", actual size = ", stored_size); |
| 286 | DebugState::Instance()->Invoke(ptr, size, st); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | static constexpr int64_t kOverhead = sizeof(int64_t); |
| 291 | }; |