aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/map_field.cc
diff options
context:
space:
mode:
authorFeng Xiao <xfxyjwf@gmail.com>2014-12-03 16:31:47 -0800
committerFeng Xiao <xfxyjwf@gmail.com>2014-12-03 16:31:47 -0800
commit137dd0f17f91ca008fa2ab0a17b1e02865e8f8ca (patch)
tree75450f3a5f3819eba4b061ec20c96e8936685834 /src/google/protobuf/map_field.cc
parent35ef68056cf84f581c2eab389f78a876f13cd661 (diff)
downloadprotobuf-137dd0f17f91ca008fa2ab0a17b1e02865e8f8ca.tar.gz
protobuf-137dd0f17f91ca008fa2ab0a17b1e02865e8f8ca.tar.bz2
protobuf-137dd0f17f91ca008fa2ab0a17b1e02865e8f8ca.zip
Delete some globals in ShutdownProtobufLibrary().
Diffstat (limited to 'src/google/protobuf/map_field.cc')
-rw-r--r--src/google/protobuf/map_field.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/google/protobuf/map_field.cc b/src/google/protobuf/map_field.cc
index 74431628..b535ec28 100644
--- a/src/google/protobuf/map_field.cc
+++ b/src/google/protobuf/map_field.cc
@@ -30,10 +30,37 @@
#include <google/protobuf/map_field.h>
+#include <vector>
+
namespace google {
namespace protobuf {
namespace internal {
+ProtobufOnceType map_entry_default_instances_once_;
+Mutex* map_entry_default_instances_mutex_;
+vector<MessageLite*>* map_entry_default_instances_;
+
+void DeleteMapEntryDefaultInstances() {
+ for (int i = 0; i < map_entry_default_instances_->size(); ++i) {
+ delete map_entry_default_instances_->at(i);
+ }
+ delete map_entry_default_instances_mutex_;
+ delete map_entry_default_instances_;
+}
+
+void InitMapEntryDefaultInstances() {
+ map_entry_default_instances_mutex_ = new Mutex();
+ map_entry_default_instances_ = new vector<MessageLite*>();
+ OnShutdown(&DeleteMapEntryDefaultInstances);
+}
+
+void RegisterMapEntryDefaultInstance(MessageLite* default_instance) {
+ GoogleOnceInit(&map_entry_default_instances_once_,
+ &InitMapEntryDefaultInstances);
+ MutexLock lock(map_entry_default_instances_mutex_);
+ map_entry_default_instances_->push_back(default_instance);
+}
+
MapFieldBase::~MapFieldBase() {
if (repeated_field_ != NULL) delete repeated_field_;
}