Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/src/arrow/buffer_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ class ARROW_EXPORT BufferBuilder {

// Unsafe methods don't check existing size

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or we should add comment for UnsafeAppend, which == 0 is unsafe in this scenario? ( I'm open to these scenario )

void UnsafeAppend(const void* data, const int64_t length) {
if (length == 0) {
return;
}
memcpy(data_ + size_, data, static_cast<size_t>(length));
size_ += length;
}
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/arrow/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <limits>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -807,6 +808,7 @@ TEST(TestBufferBuilder, FinishEmpty) {
for (const bool shrink_to_fit : {true, false}) {
ARROW_SCOPED_TRACE("shrink_to_fit = ", shrink_to_fit);
BufferBuilder builder;
ASSERT_OK(builder.Append(std::string_view{}));
ASSERT_EQ(0, builder.length());
ASSERT_EQ(0, builder.capacity());

Expand All @@ -818,6 +820,7 @@ TEST(TestBufferBuilder, FinishEmpty) {
ARROW_SCOPED_TRACE("shrink_to_fit = ", shrink_to_fit);
BufferBuilder builder;
ASSERT_OK(builder.Reserve(1024));
builder.UnsafeAppend(std::string_view{});
ASSERT_EQ(0, builder.length());
ASSERT_EQ(1024, builder.capacity());

Expand Down
Loading