Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h

Issue 1322483002: Revert https://codereview.chromium.org/1291903002 (protobuf roll). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h
diff --git a/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h b/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h
index fa20f208862a3bc1271652aef1075029e5287bef..144f44f0635304bd7acc72ae628eab2d0a1998d3 100644
--- a/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h
+++ b/third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
+// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -36,9 +36,7 @@
#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
-#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <string>
#include <google/protobuf/stubs/stl_util.h>
@@ -52,12 +50,10 @@ inline bool CodedInputStream::InternalReadStringInline(string* buffer,
if (BufferSize() >= size) {
STLStringResizeUninitialized(buffer, size);
- std::pair<char*, bool> z = as_string_data(buffer);
- if (z.second) {
- // Oddly enough, memcpy() requires its first two args to be non-NULL even
- // if we copy 0 bytes. So, we have ensured that z.first is non-NULL here.
- GOOGLE_DCHECK(z.first != NULL);
- memcpy(z.first, buffer_, size);
+ // When buffer is empty, string_as_array(buffer) will return NULL but memcpy
+ // requires non-NULL pointers even when size is 0. Hench this check.
+ if (size > 0) {
+ memcpy(string_as_array(buffer), buffer_, size);
Advance(size);
}
return true;
@@ -66,23 +62,6 @@ inline bool CodedInputStream::InternalReadStringInline(string* buffer,
return ReadStringFallback(buffer, size);
}
-inline bool CodedInputStream::InternalReadRawInline(void* buffer, int size) {
- int current_buffer_size;
- while ((current_buffer_size = BufferSize()) < size) {
- // Reading past end of buffer. Copy what we have, then refresh.
- memcpy(buffer, buffer_, current_buffer_size);
- buffer = reinterpret_cast<uint8*>(buffer) + current_buffer_size;
- size -= current_buffer_size;
- Advance(current_buffer_size);
- if (!Refresh()) return false;
- }
-
- memcpy(buffer, buffer_, size);
- Advance(size);
-
- return true;
-}
-
} // namespace io
} // namespace protobuf
} // namespace google

Powered by Google App Engine
This is Rietveld 408576698