Commit 329d103b authored by liujisi@google.com's avatar liujisi@google.com

Set pointers to NULL after shutdown, so the shutdown function can be called for multiple times.

parent f5d5b4de
...@@ -857,12 +857,14 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { ...@@ -857,12 +857,14 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) {
void MessageGenerator:: void MessageGenerator::
GenerateShutdownCode(io::Printer* printer) { GenerateShutdownCode(io::Printer* printer) {
printer->Print( printer->Print(
"delete $classname$::default_instance_;\n", "delete $classname$::default_instance_;\n"
"$classname$::default_instance_ = NULL;\n",
"classname", classname_); "classname", classname_);
if (HasDescriptorMethods(descriptor_->file())) { if (HasDescriptorMethods(descriptor_->file())) {
printer->Print( printer->Print(
"delete $classname$_reflection_;\n", "delete $classname$_reflection_;\n"
"$classname$_reflection_ = NULL;\n",
"classname", classname_); "classname", classname_);
} }
......
...@@ -251,7 +251,8 @@ void StringFieldGenerator:: ...@@ -251,7 +251,8 @@ void StringFieldGenerator::
GenerateShutdownCode(io::Printer* printer) const { GenerateShutdownCode(io::Printer* printer) const {
if (!descriptor_->default_value_string().empty()) { if (!descriptor_->default_value_string().empty()) {
printer->Print(variables_, printer->Print(variables_,
"delete $classname$::$default_variable$;\n"); "delete $classname$::$default_variable$;\n"
"$classname$::$default_variable$ = NULL;\n");
} }
} }
......
...@@ -115,11 +115,17 @@ void protobuf_RegisterTypes(const ::std::string&) { ...@@ -115,11 +115,17 @@ void protobuf_RegisterTypes(const ::std::string&) {
void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
delete CodeGeneratorRequest::default_instance_; delete CodeGeneratorRequest::default_instance_;
CodeGeneratorRequest::default_instance_ = NULL;
delete CodeGeneratorRequest_reflection_; delete CodeGeneratorRequest_reflection_;
CodeGeneratorRequest_reflection_ = NULL;
delete CodeGeneratorResponse::default_instance_; delete CodeGeneratorResponse::default_instance_;
CodeGeneratorResponse::default_instance_ = NULL;
delete CodeGeneratorResponse_reflection_; delete CodeGeneratorResponse_reflection_;
CodeGeneratorResponse_reflection_ = NULL;
delete CodeGeneratorResponse_File::default_instance_; delete CodeGeneratorResponse_File::default_instance_;
CodeGeneratorResponse_File::default_instance_ = NULL;
delete CodeGeneratorResponse_File_reflection_; delete CodeGeneratorResponse_File_reflection_;
CodeGeneratorResponse_File_reflection_ = NULL;
} }
void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
......
...@@ -518,45 +518,85 @@ void protobuf_RegisterTypes(const ::std::string&) { ...@@ -518,45 +518,85 @@ void protobuf_RegisterTypes(const ::std::string&) {
void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() {
delete FileDescriptorSet::default_instance_; delete FileDescriptorSet::default_instance_;
FileDescriptorSet::default_instance_ = NULL;
delete FileDescriptorSet_reflection_; delete FileDescriptorSet_reflection_;
FileDescriptorSet_reflection_ = NULL;
delete FileDescriptorProto::default_instance_; delete FileDescriptorProto::default_instance_;
FileDescriptorProto::default_instance_ = NULL;
delete FileDescriptorProto_reflection_; delete FileDescriptorProto_reflection_;
FileDescriptorProto_reflection_ = NULL;
delete DescriptorProto::default_instance_; delete DescriptorProto::default_instance_;
DescriptorProto::default_instance_ = NULL;
delete DescriptorProto_reflection_; delete DescriptorProto_reflection_;
DescriptorProto_reflection_ = NULL;
delete DescriptorProto_ExtensionRange::default_instance_; delete DescriptorProto_ExtensionRange::default_instance_;
DescriptorProto_ExtensionRange::default_instance_ = NULL;
delete DescriptorProto_ExtensionRange_reflection_; delete DescriptorProto_ExtensionRange_reflection_;
DescriptorProto_ExtensionRange_reflection_ = NULL;
delete FieldDescriptorProto::default_instance_; delete FieldDescriptorProto::default_instance_;
FieldDescriptorProto::default_instance_ = NULL;
delete FieldDescriptorProto_reflection_; delete FieldDescriptorProto_reflection_;
FieldDescriptorProto_reflection_ = NULL;
delete EnumDescriptorProto::default_instance_; delete EnumDescriptorProto::default_instance_;
EnumDescriptorProto::default_instance_ = NULL;
delete EnumDescriptorProto_reflection_; delete EnumDescriptorProto_reflection_;
EnumDescriptorProto_reflection_ = NULL;
delete EnumValueDescriptorProto::default_instance_; delete EnumValueDescriptorProto::default_instance_;
EnumValueDescriptorProto::default_instance_ = NULL;
delete EnumValueDescriptorProto_reflection_; delete EnumValueDescriptorProto_reflection_;
EnumValueDescriptorProto_reflection_ = NULL;
delete ServiceDescriptorProto::default_instance_; delete ServiceDescriptorProto::default_instance_;
ServiceDescriptorProto::default_instance_ = NULL;
delete ServiceDescriptorProto_reflection_; delete ServiceDescriptorProto_reflection_;
ServiceDescriptorProto_reflection_ = NULL;
delete MethodDescriptorProto::default_instance_; delete MethodDescriptorProto::default_instance_;
MethodDescriptorProto::default_instance_ = NULL;
delete MethodDescriptorProto_reflection_; delete MethodDescriptorProto_reflection_;
MethodDescriptorProto_reflection_ = NULL;
delete FileOptions::default_instance_; delete FileOptions::default_instance_;
FileOptions::default_instance_ = NULL;
delete FileOptions_reflection_; delete FileOptions_reflection_;
FileOptions_reflection_ = NULL;
delete MessageOptions::default_instance_; delete MessageOptions::default_instance_;
MessageOptions::default_instance_ = NULL;
delete MessageOptions_reflection_; delete MessageOptions_reflection_;
MessageOptions_reflection_ = NULL;
delete FieldOptions::default_instance_; delete FieldOptions::default_instance_;
FieldOptions::default_instance_ = NULL;
delete FieldOptions_reflection_; delete FieldOptions_reflection_;
FieldOptions_reflection_ = NULL;
delete EnumOptions::default_instance_; delete EnumOptions::default_instance_;
EnumOptions::default_instance_ = NULL;
delete EnumOptions_reflection_; delete EnumOptions_reflection_;
EnumOptions_reflection_ = NULL;
delete EnumValueOptions::default_instance_; delete EnumValueOptions::default_instance_;
EnumValueOptions::default_instance_ = NULL;
delete EnumValueOptions_reflection_; delete EnumValueOptions_reflection_;
EnumValueOptions_reflection_ = NULL;
delete ServiceOptions::default_instance_; delete ServiceOptions::default_instance_;
ServiceOptions::default_instance_ = NULL;
delete ServiceOptions_reflection_; delete ServiceOptions_reflection_;
ServiceOptions_reflection_ = NULL;
delete MethodOptions::default_instance_; delete MethodOptions::default_instance_;
MethodOptions::default_instance_ = NULL;
delete MethodOptions_reflection_; delete MethodOptions_reflection_;
MethodOptions_reflection_ = NULL;
delete UninterpretedOption::default_instance_; delete UninterpretedOption::default_instance_;
UninterpretedOption::default_instance_ = NULL;
delete UninterpretedOption_reflection_; delete UninterpretedOption_reflection_;
UninterpretedOption_reflection_ = NULL;
delete UninterpretedOption_NamePart::default_instance_; delete UninterpretedOption_NamePart::default_instance_;
UninterpretedOption_NamePart::default_instance_ = NULL;
delete UninterpretedOption_NamePart_reflection_; delete UninterpretedOption_NamePart_reflection_;
UninterpretedOption_NamePart_reflection_ = NULL;
delete SourceCodeInfo::default_instance_; delete SourceCodeInfo::default_instance_;
SourceCodeInfo::default_instance_ = NULL;
delete SourceCodeInfo_reflection_; delete SourceCodeInfo_reflection_;
SourceCodeInfo_reflection_ = NULL;
delete SourceCodeInfo_Location::default_instance_; delete SourceCodeInfo_Location::default_instance_;
SourceCodeInfo_Location::default_instance_ = NULL;
delete SourceCodeInfo_Location_reflection_; delete SourceCodeInfo_Location_reflection_;
SourceCodeInfo_Location_reflection_ = NULL;
} }
void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment