Repository: arrow Updated Branches: refs/heads/master df2220f35 -> cd4544df8
ARROW-664: [C++] Make C++ Arrow serialization deterministic Author: Philipp Moritz <pcmor...@gmail.com> Closes #405 from pcmoritz/init-buffer-builder and squashes the following commits: 10a897f [Philipp Moritz] Initialize memory obtained by BufferBuilder to zero Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/cd4544df Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/cd4544df Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/cd4544df Branch: refs/heads/master Commit: cd4544df89b60641f49bbb3104043c0ae07ef8a9 Parents: df2220f Author: Philipp Moritz <pcmor...@gmail.com> Authored: Mon Mar 20 10:54:57 2017 +0100 Committer: Uwe L. Korn <uw...@xhochy.com> Committed: Mon Mar 20 10:54:57 2017 +0100 ---------------------------------------------------------------------- cpp/src/arrow/buffer.h | 4 ++++ 1 file changed, 4 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/cd4544df/cpp/src/arrow/buffer.h ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h index 1647e86..70c16a2 100644 --- a/cpp/src/arrow/buffer.h +++ b/cpp/src/arrow/buffer.h @@ -170,9 +170,13 @@ class ARROW_EXPORT BufferBuilder { // Resize(0) is a no-op if (elements == 0) { return Status::OK(); } if (capacity_ == 0) { buffer_ = std::make_shared<PoolBuffer>(pool_); } + int64_t old_capacity = capacity_; RETURN_NOT_OK(buffer_->Resize(elements)); capacity_ = buffer_->capacity(); data_ = buffer_->mutable_data(); + if (capacity_ > old_capacity) { + memset(data_ + old_capacity, 0, capacity_ - old_capacity); + } return Status::OK(); }