Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-1600: [C++] Add Buffer constructor that wraps std::string #1147

Closed
wants to merge 2 commits into from

Conversation

wesm
Copy link
Member

@wesm wesm commented Sep 29, 2017

Many other libraries interchange binary data with std::string. This makes it easy to wrap such data in an arrow::Buffer.

It may be worth adding a function that creates a buffer from a string, but owns its memory.

I also deprecated arrow::GetBufferFromString, which shouldn't have been public in the first place, since the new ctor is more general

Change-Id: Ic41686a276f35c61f4fa0aca9f79f2b4c3e91482
Copy link
Contributor

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor comments.

@@ -46,6 +46,14 @@ TEST_F(TestBuffer, IsMutableFlag) {
ASSERT_TRUE(pbuf.is_mutable());
}

TEST_F(TestBuffer, FromStdString) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be TEST_F or can it just be TEST? It doesn't appear to be using any of the members of TestBuffer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the fixture and made everything TEST since none of them were using it

/// \param[in] data a memory buffer
/// \param[in] size buffer size
///
/// \note The passed memory must be kept alive through some other means
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would ASAN be able to detect this kind of lifetime error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, and you would segfault if you tried accessing the memory that had already been freed

Change-Id: If2e103879b5627c12b717eab459a248b0b89cf20
@asfgit asfgit closed this in 7c61611 Sep 30, 2017
@wesm wesm deleted the ARROW-1600 branch September 30, 2017 04:02
wesm added a commit to wesm/arrow that referenced this pull request Oct 3, 2017
Many other libraries interchange binary data with `std::string`. This makes it easy to wrap such data in an `arrow::Buffer`.

It may be worth adding a function that creates a buffer from a string, but owns its memory.

I also deprecated `arrow::GetBufferFromString`, which shouldn't have been public in the first place, since the new ctor is more general

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes apache#1147 from wesm/ARROW-1600 and squashes the following commits:

f60f502 [Wes McKinney] Remove TestBuffer fixture
644bf2b [Wes McKinney] Add Buffer ctor that wraps std::string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants