You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/07/13 16:56:19 UTC

[GitHub] [arrow] bkietz commented on a change in pull request #7731: ARROW-9428: [C++][Doc] Update buffer allocation documentation

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:
users@infra.apache.org