Index: third_party/protobuf/src/google/protobuf/repeated_field.cc |
diff --git a/third_party/protobuf/src/google/protobuf/repeated_field.cc b/third_party/protobuf/src/google/protobuf/repeated_field.cc |
index 5ca964c16776a8c4070da208413da84d431f1d4f..77004f59af9ce53f7727fc56bc8aba4d5969f267 100644 |
--- a/third_party/protobuf/src/google/protobuf/repeated_field.cc |
+++ b/third_party/protobuf/src/google/protobuf/repeated_field.cc |
@@ -58,16 +58,14 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { |
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / |
sizeof(old_rep->elements[0])) |
<< "Requested size is too large to fit into size_t."; |
- size_t bytes = kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size; |
if (arena == NULL) { |
- rep_ = reinterpret_cast<Rep*>(::operator new(bytes)); |
+ rep_ = reinterpret_cast<Rep*>( |
+ new char[kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size]); |
} else { |
rep_ = reinterpret_cast<Rep*>( |
- ::google::protobuf::Arena::CreateArray<char>(arena, bytes)); |
+ ::google::protobuf::Arena::CreateArray<char>(arena, |
+ kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size)); |
} |
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) |
- const int old_total_size = total_size_; |
-#endif |
total_size_ = new_size; |
if (old_rep && old_rep->allocated_size > 0) { |
memcpy(rep_->elements, old_rep->elements, |
@@ -77,13 +75,7 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { |
rep_->allocated_size = 0; |
} |
if (arena == NULL) { |
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) |
- const size_t old_size = |
- old_total_size * sizeof(rep_->elements[0]) + kRepHeaderSize; |
- ::operator delete(static_cast<void*>(old_rep), old_size); |
-#else |
- ::operator delete(static_cast<void*>(old_rep)); |
-#endif |
+ delete [] reinterpret_cast<char*>(old_rep); |
} |
return &rep_->elements[current_size_]; |
} |