aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/repeated_field.h
diff options
context:
space:
mode:
authorGravatar Bo Yang <teboring@google.com>2017-06-23 12:56:44 -0700
committerGravatar Bo Yang <paulyang1211@gmail.com>2017-06-24 11:28:13 -0700
commite3c807d4e752b477b707f5d021264faf9b127304 (patch)
tree505092dff769b14d6a07be62314bc948b9398090 /src/google/protobuf/repeated_field.h
parent9c0b35cf620c4904a18e25733f50c9c0474fefa6 (diff)
Fix more implicit type conversions in public headers and generated code.
Diffstat (limited to 'src/google/protobuf/repeated_field.h')
-rw-r--r--src/google/protobuf/repeated_field.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index a1013f63..02ee3cc9 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -1335,7 +1335,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
static_cast<size_t>(new_size),
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
<< "Requested size is too large to fit into size_t.";
- size_t bytes = kRepHeaderSize + sizeof(Element) * new_size;
+ size_t bytes = kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size);
if (arena == NULL) {
rep_ = static_cast<Rep*>(::operator new(bytes));
} else {
@@ -1399,7 +1399,7 @@ void ElementCopier<Element, HasTrivialCopy>::operator()(
template <typename Element>
struct ElementCopier<Element, true> {
void operator()(Element* to, const Element* from, int array_size) {
- memcpy(to, from, array_size * sizeof(Element));
+ memcpy(to, from, static_cast<size_t>(array_size) * sizeof(Element));
}
};
@@ -1651,7 +1651,7 @@ inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {
template <typename TypeHandler>
inline size_t RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() const {
- size_t allocated_bytes = total_size_ * sizeof(void*);
+ size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*);
if (rep_ != NULL) {
for (int i = 0; i < rep_->allocated_size; ++i) {
allocated_bytes += TypeHandler::SpaceUsedLong(