aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/generated_message_util.cc
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@gmail.com>2018-07-09 09:35:48 -0700
committerGravatar GitHub <noreply@github.com>2018-07-09 09:35:48 -0700
commite1845779ed1115dd61eb2a3b8f0a78c252ca5b2b (patch)
treefdb892e4e34269f6b3bbb6f629a912d4c63c2d70 /src/google/protobuf/generated_message_util.cc
parentf7ada1280fac4af717d478e6a9765d3f02b418b3 (diff)
parenta9abc7831e45257d334cfa682746b6cadf9e95d9 (diff)
Merge pull request #4878 from acozzette/fix-msvc-initialization
Fix initialization with Visual Studio
Diffstat (limited to 'src/google/protobuf/generated_message_util.cc')
-rw-r--r--src/google/protobuf/generated_message_util.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc
index dac8ca90..e0241361 100644
--- a/src/google/protobuf/generated_message_util.cc
+++ b/src/google/protobuf/generated_message_util.cc
@@ -57,6 +57,12 @@ namespace google {
namespace protobuf {
namespace internal {
+void DestroyMessage(const void* message) {
+ static_cast<const MessageLite*>(message)->~MessageLite();
+}
+void DestroyString(const void* s) { static_cast<const string*>(s)->~string(); }
+
+ExplicitlyConstructed<std::string> fixed_address_empty_string;
double Infinity() {
return std::numeric_limits<double>::infinity();
@@ -65,14 +71,15 @@ double NaN() {
return std::numeric_limits<double>::quiet_NaN();
}
-ExplicitlyConstructed<::std::string> fixed_address_empty_string;
-GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
-
-void DeleteEmptyString() { fixed_address_empty_string.Destruct(); }
-
-void InitEmptyString() {
+static bool InitProtobufDefaultsImpl() {
fixed_address_empty_string.DefaultConstruct();
- OnShutdown(&DeleteEmptyString);
+ OnShutdownDestroyString(fixed_address_empty_string.get_mutable());
+ return true;
+}
+
+void InitProtobufDefaults() {
+ static bool is_inited = InitProtobufDefaultsImpl();
+ (void)is_inited;
}
size_t StringSpaceUsedExcludingSelfLong(const string& str) {
@@ -86,12 +93,6 @@ size_t StringSpaceUsedExcludingSelfLong(const string& str) {
}
}
-
-
-void InitProtobufDefaults() {
- GetEmptyString();
-}
-
template <typename T>
const T& Get(const void* ptr) {
return *static_cast<const T*>(ptr);