| 938 | } |
| 939 | |
| 940 | Status Resize(const int64_t new_size, bool shrink_to_fit = true) override { |
| 941 | if (ARROW_PREDICT_FALSE(new_size < 0)) { |
| 942 | return Status::Invalid("Negative buffer resize: ", new_size); |
| 943 | } |
| 944 | uint8_t* ptr = mutable_data(); |
| 945 | if (ptr && shrink_to_fit && new_size <= size_) { |
| 946 | // Buffer is non-null and is not growing, so shrink to the requested size without |
| 947 | // excess space. |
| 948 | ARROW_ASSIGN_OR_RAISE(int64_t new_capacity, RoundCapacity(new_size)); |
| 949 | if (capacity_ != new_capacity) { |
| 950 | // Buffer hasn't got yet the requested size. |
| 951 | RETURN_NOT_OK(pool_->Reallocate(capacity_, new_capacity, alignment_, &ptr)); |
| 952 | data_ = ptr; |
| 953 | capacity_ = new_capacity; |
| 954 | } |
| 955 | } else { |
| 956 | RETURN_NOT_OK(Reserve(new_size)); |
| 957 | } |
| 958 | size_ = new_size; |
| 959 | |
| 960 | return Status::OK(); |
| 961 | } |
| 962 | |
| 963 | static std::shared_ptr<PoolBuffer> MakeShared(MemoryPool* pool, int64_t alignment) { |
| 964 | std::shared_ptr<MemoryManager> mm; |
no test coverage detected