| 233 | static void ReleaseUnused() { WrappedAllocator::ReleaseUnused(); } |
| 234 | |
| 235 | static Status ReallocateAligned(int64_t old_size, int64_t new_size, int64_t alignment, |
| 236 | uint8_t** ptr) { |
| 237 | CheckAllocatedArea(*ptr, old_size, "reallocation"); |
| 238 | if (*ptr == memory_pool::internal::kZeroSizeArea) { |
| 239 | return AllocateAligned(new_size, alignment, ptr); |
| 240 | } |
| 241 | if (new_size == 0) { |
| 242 | // Note that an overflow check isn't needed as `old_size` is supposed to have |
| 243 | // been successfully passed to AllocateAligned() before. |
| 244 | WrappedAllocator::DeallocateAligned(*ptr, old_size + kOverhead, alignment); |
| 245 | *ptr = memory_pool::internal::kZeroSizeArea; |
| 246 | return Status::OK(); |
| 247 | } |
| 248 | ARROW_ASSIGN_OR_RAISE(int64_t raw_new_size, RawSize(new_size)); |
| 249 | DCHECK(raw_new_size > new_size) |
| 250 | << "bug in raw size computation: " << raw_new_size << " for size " << new_size; |
| 251 | RETURN_NOT_OK(WrappedAllocator::ReallocateAligned(old_size + kOverhead, raw_new_size, |
| 252 | alignment, ptr)); |
| 253 | InitAllocatedArea(*ptr, new_size); |
| 254 | return Status::OK(); |
| 255 | } |
| 256 | |
| 257 | static void DeallocateAligned(uint8_t* ptr, int64_t size, int64_t alignment) { |
| 258 | CheckAllocatedArea(ptr, size, "deallocation"); |