From 778178479626b0e5b4de0701103a1bb0a067702d Mon Sep 17 00:00:00 2001 From: Gerben Stavenga Date: Wed, 2 Aug 2017 18:25:28 -0700 Subject: Add destructors for default instances to the shutdown code. Verified test succeed under draconian heap checker --- src/google/protobuf/stubs/common.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100644 => 100755 src/google/protobuf/stubs/common.cc (limited to 'src/google/protobuf/stubs/common.cc') diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc old mode 100644 new mode 100755 index 78aa4d64..73822168 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -30,6 +30,7 @@ // Author: kenton@google.com (Kenton Varda) +#include // TODO(gerbens) ideally remove this. #include #include #include @@ -424,10 +425,14 @@ struct ShutdownData { for (int i = 0; i < strings.size(); i++) { strings[i]->~string(); } + for (int i = 0; i < messages.size(); i++) { + messages[i]->~MessageLite(); + } } vector functions; vector strings; + vector messages; Mutex mutex; }; @@ -454,6 +459,12 @@ void OnShutdownDestroyString(const std::string* ptr) { shutdown_data->strings.push_back(ptr); } +void OnShutdownDestroyMessage(const void* ptr) { + InitShutdownFunctionsOnce(); + MutexLock lock(&shutdown_data->mutex); + shutdown_data->messages.push_back(static_cast(ptr)); +} + } // namespace internal void ShutdownProtobufLibrary() { -- cgit v1.2.3