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

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

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Update to new HEAD (b7632464b4) + restore GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER Created 4 years, 1 month 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 334051a013e4098afea6eed399a54caae30ac729..c4c8eefce259d74ba676bf777364d33cdd96eb20 100644
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.cc
+++ b/third_party/protobuf/src/google/protobuf/generated_message_util.cc
@@ -48,24 +48,27 @@ double NaN() {
return std::numeric_limits<double>::quiet_NaN();
}
-const ::std::string* empty_string_;
+ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
void DeleteEmptyString() {
- delete empty_string_;
+ GetEmptyStringAlreadyInited().~string();
}
void InitEmptyString() {
- empty_string_ = new string;
+ fixed_address_empty_string.DefaultConstruct();
OnShutdown(&DeleteEmptyString);
}
+const ::std::string& GetEmptyStringAlreadyInited() {
+ return fixed_address_empty_string.get();
+}
+
const ::std::string& GetEmptyString() {
::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
return GetEmptyStringAlreadyInited();
}
-
int StringSpaceUsedExcludingSelf(const string& str) {
const void* start = &str;
const void* end = &str + 1;
@@ -79,6 +82,12 @@ int StringSpaceUsedExcludingSelf(const string& str) {
+void MergeFromFail(const char* file, int line) {
+ GOOGLE_CHECK(false) << file << ":" << line;
+ // Open-source GOOGLE_CHECK(false) is not NORETURN.
+ exit(1);
+}
+
} // namespace internal
} // namespace protobuf
} // namespace google

Powered by Google App Engine
This is Rietveld 408576698