Files
ray/thirdparty/scripts/arrow-zero-fill.patch
T
2018-07-06 13:18:56 -07:00

31 lines
1.1 KiB
Diff

diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc
index 34bd600e..3ef32090 100644
--- a/cpp/src/arrow/memory_pool.cc
+++ b/cpp/src/arrow/memory_pool.cc
@@ -53,6 +53,7 @@ Status AllocateAligned(int64_t size, uint8_t** out) {
ss << "malloc of size " << size << " failed";
return Status::OutOfMemory(ss.str());
}
+ memset(*out, 0, size);
#elif defined(ARROW_JEMALLOC)
*out = reinterpret_cast<uint8_t*>(mallocx(
std::max(static_cast<size_t>(size), kAlignment), MALLOCX_ALIGN(kAlignment)));
@@ -75,6 +76,7 @@ Status AllocateAligned(int64_t size, uint8_t** out) {
ss << "invalid alignment parameter: " << kAlignment;
return Status::Invalid(ss.str());
}
+ memset(*out, 0, size);
#endif
return Status::OK();
}
@@ -124,6 +126,9 @@ class DefaultMemoryPool : public MemoryPool {
DCHECK(out);
// Copy contents and release old memory chunk
memcpy(out, *ptr, static_cast<size_t>(std::min(new_size, old_size)));
+ if (new_size > old_size) {
+ memset(out + old_size, 0, static_cast<size_t>(new_size - old_size));
+ }
#ifdef _MSC_VER
_aligned_free(*ptr);
#else