[
https://issues.apache.org/jira/browse/ARROW-1623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16345814#comment-16345814
]
ASF GitHub Bot commented on ARROW-1623:
---------------------------------------
wesm commented on a change in pull request #1518: ARROW-1623: [C++] Add
convenience method to construct Buffer from a string that owns its memory
URL: https://github.com/apache/arrow/pull/1518#discussion_r164878557
##########
File path: cpp/src/arrow/buffer-test.cc
##########
@@ -52,6 +52,22 @@ TEST(TestBuffer, FromStdString) {
ASSERT_EQ(static_cast<int64_t>(val.size()), buf.size());
}
+TEST(TestBuffer, FromStdStringWithMemory) {
+ std::string* val = new std::string("hello, world");
+ std::shared_ptr<Buffer> buf;
+ std::string expected("hello, world");
+
+ ASSERT_OK(Buffer::FromString(*val, default_memory_pool(), &buf));
+
+ ASSERT_EQ(0, memcmp(buf->data(), val->c_str(), val->size()));
+ ASSERT_EQ(static_cast<int64_t>(val->size()), buf->size());
+
+ delete val;
Review comment:
Note we do not use `new` and `delete` in this codebase except in rare
situations (we have to use `new` to initialize `std::unique_ptr` because we do
not yet have `std::make_unique`).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [C++] Add convenience method to construct Buffer from a string that owns its
> memory
> -----------------------------------------------------------------------------------
>
> Key: ARROW-1623
> URL: https://issues.apache.org/jira/browse/ARROW-1623
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C++
> Reporter: Wes McKinney
> Assignee: Panchen Xue
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> The memory would need to be allocated from a memory pool / buffer allocator
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)