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 |