| Index: third_party/protobuf/src/google/protobuf/io/coded_stream.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/io/coded_stream.cc b/third_party/protobuf/src/google/protobuf/io/coded_stream.cc
|
| index 4bcd354fe6de4baa6d38ba71f8ed0ee5116903b8..d8354c1f9cef5d46543873e229852bffb178472e 100644
|
| --- a/third_party/protobuf/src/google/protobuf/io/coded_stream.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/io/coded_stream.cc
|
| @@ -105,7 +105,7 @@ void CodedInputStream::BackUpInputToCurrentPosition() {
|
|
|
| inline void CodedInputStream::RecomputeBufferLimits() {
|
| buffer_end_ += buffer_size_after_limit_;
|
| - int closest_limit = min(current_limit_, total_bytes_limit_);
|
| + int closest_limit = std::min(current_limit_, total_bytes_limit_);
|
| if (closest_limit < total_bytes_read_) {
|
| // The limit position is in the current buffer. We must adjust
|
| // the buffer size accordingly.
|
| @@ -135,7 +135,7 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {
|
| // We need to enforce all limits, not just the new one, so if the previous
|
| // limit was before the new requested limit, we continue to enforce the
|
| // previous limit.
|
| - current_limit_ = min(current_limit_, old_limit);
|
| + current_limit_ = std::min(current_limit_, old_limit);
|
|
|
| RecomputeBufferLimits();
|
| return old_limit;
|
| @@ -188,7 +188,7 @@ void CodedInputStream::SetTotalBytesLimit(
|
| // Make sure the limit isn't already past, since this could confuse other
|
| // code.
|
| int current_position = CurrentPosition();
|
| - total_bytes_limit_ = max(current_position, total_bytes_limit);
|
| + total_bytes_limit_ = std::max(current_position, total_bytes_limit);
|
| if (warning_threshold >= 0) {
|
| total_bytes_warning_threshold_ = warning_threshold;
|
| } else {
|
| @@ -233,7 +233,7 @@ bool CodedInputStream::Skip(int count) {
|
| buffer_end_ = buffer_;
|
|
|
| // Make sure this skip doesn't try to skip past the current limit.
|
| - int closest_limit = min(current_limit_, total_bytes_limit_);
|
| + int closest_limit = std::min(current_limit_, total_bytes_limit_);
|
| int bytes_until_limit = closest_limit - total_bytes_read_;
|
| if (bytes_until_limit < count) {
|
| // We hit the limit. Skip up to it then fail.
|
| @@ -270,7 +270,7 @@ bool CodedInputStream::ReadStringFallback(string* buffer, int size) {
|
| buffer->clear();
|
| }
|
|
|
| - int closest_limit = min(current_limit_, total_bytes_limit_);
|
| + int closest_limit = std::min(current_limit_, total_bytes_limit_);
|
| if (closest_limit != INT_MAX) {
|
| int bytes_to_limit = closest_limit - CurrentPosition();
|
| if (bytes_to_limit > 0 && size > 0 && size <= bytes_to_limit) {
|
| @@ -629,6 +629,24 @@ CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output)
|
| had_error_ = false;
|
| }
|
|
|
| +CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output,
|
| + bool do_eager_refresh)
|
| + : output_(output),
|
| + buffer_(NULL),
|
| + buffer_size_(0),
|
| + total_bytes_(0),
|
| + had_error_(false),
|
| + aliasing_enabled_(false) {
|
| + if (do_eager_refresh) {
|
| + // Eagerly Refresh() so buffer space is immediately available.
|
| + Refresh();
|
| + // The Refresh() may have failed. If the client doesn't write any data,
|
| + // though, don't consider this an error. If the client does write data, then
|
| + // another Refresh() will be attempted and it will set the error once again.
|
| + had_error_ = false;
|
| + }
|
| +}
|
| +
|
| CodedOutputStream::~CodedOutputStream() {
|
| Trim();
|
| }
|
|
|