| 241 | } |
| 242 | |
| 243 | Status BufferPool::AllocateUnreservedBuffer( |
| 244 | ClientHandle* client, int64_t len, BufferHandle* handle) { |
| 245 | DCHECK(!handle->is_open()); |
| 246 | bool success; |
| 247 | RETURN_IF_ERROR(client->impl_->PrepareToAllocateBuffer(len, false, &success)); |
| 248 | if (!success) return Status::OK(); // Leave 'handle' closed to indicate failure. |
| 249 | |
| 250 | Status status = allocator_->Allocate(client, len, handle); |
| 251 | // If the allocation failed, update client's accounting to reflect the failure. |
| 252 | if (!status.ok()) client->impl_->FreedBuffer(len); |
| 253 | return status; |
| 254 | } |
| 255 | |
| 256 | void BufferPool::FreeBuffer(ClientHandle* client, BufferHandle* handle) { |
| 257 | if (!handle->is_open()) return; // Should be idempotent. |