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

Unified Diff: third_party/protobuf/src/google/protobuf/generated_message_util.cc

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 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/generated_message_util.cc
diff --git a/third_party/protobuf/src/google/protobuf/generated_message_util.cc b/third_party/protobuf/src/google/protobuf/generated_message_util.cc
index 92882d79ce7ae63cbf1964fc20474a0db6115609..334051a013e4098afea6eed399a54caae30ac729 100644
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.cc
+++ b/third_party/protobuf/src/google/protobuf/generated_message_util.cc
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -36,6 +36,7 @@
#include <limits>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -48,17 +49,36 @@ double NaN() {
}
const ::std::string* empty_string_;
-ProtobufOnceType empty_string_once_init_;
+GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
+
+void DeleteEmptyString() {
+ delete empty_string_;
+}
void InitEmptyString() {
- empty_string_ = new std::string();
+ empty_string_ = new string;
+ OnShutdown(&DeleteEmptyString);
}
const ::std::string& GetEmptyString() {
- GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
- return *empty_string_;
+ ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
+ return GetEmptyStringAlreadyInited();
+}
+
+
+int StringSpaceUsedExcludingSelf(const string& str) {
+ const void* start = &str;
+ const void* end = &str + 1;
+ if (start <= str.data() && str.data() < end) {
+ // The string's data is stored inside the string object itself.
+ return 0;
+ } else {
+ return str.capacity();
+ }
}
+
+
} // namespace internal
} // namespace protobuf
} // namespace google

Powered by Google App Engine
This is Rietveld 408576698