bkietz commented on a change in pull request #7731:
URL: https://github.com/apache/arrow/pull/7731#discussion_r453792540



##########
File path: docs/source/cpp/memory.rst
##########
@@ -71,11 +74,12 @@ You can allocate a buffer yourself by calling one of the
 :func:`arrow::AllocateBuffer` or :func:`arrow::AllocateResizableBuffer`
 overloads::
 
-   std::shared_ptr<arrow::Buffer> buffer;
-
-   if (!arrow::AllocateBuffer(4096, &buffer).ok()) {
+   auto maybe_buffer = arrow::AllocateBuffer(4096);
+   if (!maybe_buffer.ok()) {
       // ... handle allocation error
    }
+
+   std::shared_ptr<arrow::Buffer> buffer = *maybe_buffer;

Review comment:
       Hmmm, I think we should be clearer about the type here
   ```suggestion
      arrow::Result<std::unique_ptr<Buffer>> maybe_buffer = 
arrow::AllocateBuffer(4096);
      if (!maybe_buffer.ok()) {
         // ... handle allocation error
      }
   
      std::shared_ptr<arrow::Buffer> buffer = *std::move(maybe_buffer);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to