aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/common.cc
diff options
context:
space:
mode:
authorGravatar Gerben Stavenga <gerbens@google.com>2017-08-02 18:25:28 -0700
committerGravatar Gerben Stavenga <gerbens@google.com>2017-08-02 18:25:28 -0700
commit778178479626b0e5b4de0701103a1bb0a067702d (patch)
tree2c80366a7fe6389b33764b5895e24d1bb6435971 /src/google/protobuf/stubs/common.cc
parent53ae6de18b51509e67ec84bd6363985d14750bd7 (diff)
Add destructors for default instances to the shutdown code.
Verified test succeed under draconian heap checker
Diffstat (limited to 'src/google/protobuf/stubs/common.cc')
-rwxr-xr-x[-rw-r--r--]src/google/protobuf/stubs/common.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
index 78aa4d64..73822168 100644..100755
--- 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 <google/protobuf/message_lite.h> // TODO(gerbens) ideally remove this.
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/stubs/status.h>
@@ -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<void (*)()> functions;
vector<const std::string*> strings;
+ vector<const MessageLite*> 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<const MessageLite*>(ptr));
+}
+
} // namespace internal
void ShutdownProtobufLibrary() {