Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
137dd0f1
Commit
137dd0f1
authored
Dec 04, 2014
by
Feng Xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete some globals in ShutdownProtobufLibrary().
parent
35ef6805
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
descriptor.cc
src/google/protobuf/descriptor.cc
+5
-0
map_entry.h
src/google/protobuf/map_entry.h
+5
-0
map_field.cc
src/google/protobuf/map_field.cc
+27
-0
No files found.
src/google/protobuf/descriptor.cc
View file @
137dd0f1
...
...
@@ -345,6 +345,10 @@ typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap;
set
<
string
>*
allowed_proto3_extendees_
=
NULL
;
GOOGLE_PROTOBUF_DECLARE_ONCE
(
allowed_proto3_extendees_init_
);
void
DeleteAllowedProto3Extendee
()
{
delete
allowed_proto3_extendees_
;
}
void
InitAllowedProto3Extendee
()
{
allowed_proto3_extendees_
=
new
set
<
string
>
;
allowed_proto3_extendees_
->
insert
(
"google.protobuf.FileOptions"
);
...
...
@@ -354,6 +358,7 @@ void InitAllowedProto3Extendee() {
allowed_proto3_extendees_
->
insert
(
"google.protobuf.EnumValueOptions"
);
allowed_proto3_extendees_
->
insert
(
"google.protobuf.ServiceOptions"
);
allowed_proto3_extendees_
->
insert
(
"google.protobuf.MethodOptions"
);
google
::
protobuf
::
internal
::
OnShutdown
(
&
DeleteAllowedProto3Extendee
);
}
// Checks whether the extendee type is allowed in proto3.
...
...
src/google/protobuf/map_entry.h
View file @
137dd0f1
...
...
@@ -43,6 +43,10 @@ class Arena;
namespace
protobuf
{
namespace
internal
{
// Register all MapEntry default instances so we can delete them in
// ShutdownProtobufLibrary().
void
RegisterMapEntryDefaultInstance
(
MessageLite
*
default_instance
);
// This is the common base class for MapEntry. It is used by MapFieldBase in
// reflection api, in which the static type of key and value is unknown.
class
LIBPROTOBUF_EXPORT
MapEntryBase
:
public
Message
{
...
...
@@ -317,6 +321,7 @@ class LIBPROTOBUF_EXPORT MapEntry : public MapEntryBase {
entry
->
reflection_
=
reflection
;
entry
->
default_instance_
=
entry
;
entry
->
InitAsDefaultInstance
();
RegisterMapEntryDefaultInstance
(
entry
);
return
entry
;
}
...
...
src/google/protobuf/map_field.cc
View file @
137dd0f1
...
...
@@ -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_
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment