| 32 | namespace arrow { |
| 33 | |
| 34 | Result<std::shared_ptr<Buffer>> Buffer::CopySlice(const int64_t start, |
| 35 | const int64_t nbytes, |
| 36 | MemoryPool* pool) const { |
| 37 | // Sanity checks |
| 38 | ARROW_CHECK_LE(start, size_); |
| 39 | ARROW_CHECK_LE(nbytes, size_ - start); |
| 40 | DCHECK_GE(nbytes, 0); |
| 41 | |
| 42 | ARROW_ASSIGN_OR_RAISE(auto new_buffer, AllocateResizableBuffer(nbytes, pool)); |
| 43 | std::memcpy(new_buffer->mutable_data(), data() + start, static_cast<size_t>(nbytes)); |
| 44 | return new_buffer; |
| 45 | } |
| 46 | |
| 47 | Buffer::Buffer() : Buffer(memory_pool::internal::kZeroSizeArea, 0) {} |
| 48 | |