Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: third_party/protobuf/src/google/protobuf/extension_set.cc

Issue 2885223002: Protobuf: Remove protobuf globals patch (Closed)
Patch Set: typo Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/extension_set.cc
diff --git a/third_party/protobuf/src/google/protobuf/extension_set.cc b/third_party/protobuf/src/google/protobuf/extension_set.cc
index 52daa4aa4229ddb9b43703446618e9890dcde45a..9afb236147c0cfd60c4d60b5d3bd55a833052161 100644
--- a/third_party/protobuf/src/google/protobuf/extension_set.cc
+++ b/third_party/protobuf/src/google/protobuf/extension_set.cc
@@ -46,12 +46,6 @@ namespace google {
namespace protobuf {
namespace internal {
-// Registry stuff.
-typedef hash_map<pair<const MessageLite*, int>, ExtensionInfo>
- ExtensionRegistry;
-extern ExtensionRegistry* cr_registry_;
-extern ProtobufOnceType cr_registry_init_;
-
namespace {
inline WireFormatLite::FieldType real_type(FieldType type) {
@@ -81,13 +75,19 @@ inline bool is_packable(WireFormatLite::WireType type) {
return false;
}
+// Registry stuff.
+typedef hash_map<pair<const MessageLite*, int>,
+ ExtensionInfo> ExtensionRegistry;
+ExtensionRegistry* registry_ = NULL;
+GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_);
+
void DeleteRegistry() {
- delete cr_registry_;
- cr_registry_ = NULL;
+ delete registry_;
+ registry_ = NULL;
}
void InitRegistry() {
- cr_registry_ = new ExtensionRegistry;
+ registry_ = new ExtensionRegistry;
OnShutdown(&DeleteRegistry);
}
@@ -95,9 +95,9 @@ void InitRegistry() {
// safety.
void Register(const MessageLite* containing_type,
int number, ExtensionInfo info) {
- ::google::protobuf::GoogleOnceInit(&cr_registry_init_, &InitRegistry);
+ ::google::protobuf::GoogleOnceInit(&registry_init_, &InitRegistry);
- if (!InsertIfNotPresent(cr_registry_, std::make_pair(containing_type, number),
+ if (!InsertIfNotPresent(registry_, std::make_pair(containing_type, number),
info)) {
GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \""
<< containing_type->GetTypeName()
@@ -107,10 +107,9 @@ void Register(const MessageLite* containing_type,
const ExtensionInfo* FindRegisteredExtension(
const MessageLite* containing_type, int number) {
- return (cr_registry_ == NULL)
+ return (registry_ == NULL)
? NULL
- : FindOrNull(*cr_registry_,
- std::make_pair(containing_type, number));
+ : FindOrNull(*registry_, std::make_pair(containing_type, number));
}
} // namespace
@@ -1749,45 +1748,68 @@ void ExtensionSet::Extension::Free() {
// ==================================================================
// Default repeated field instances for iterator-compatible accessors
+GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_primitive_generic_type_traits_once_init_);
+GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_string_type_traits_once_init_);
+GOOGLE_PROTOBUF_DECLARE_ONCE(repeated_message_generic_type_traits_once_init_);
+
void RepeatedPrimitiveGenericTypeTraits::InitializeDefaultRepeatedFields() {
- cr_default_repeated_field_int32_ = new RepeatedField<int32>;
- cr_default_repeated_field_int64_ = new RepeatedField<int64>;
- cr_default_repeated_field_uint32_ = new RepeatedField<uint32>;
- cr_default_repeated_field_uint64_ = new RepeatedField<uint64>;
- cr_default_repeated_field_double_ = new RepeatedField<double>;
- cr_default_repeated_field_float_ = new RepeatedField<float>;
- cr_default_repeated_field_bool_ = new RepeatedField<bool>;
+ default_repeated_field_int32_ = new RepeatedField<int32>;
+ default_repeated_field_int64_ = new RepeatedField<int64>;
+ default_repeated_field_uint32_ = new RepeatedField<uint32>;
+ default_repeated_field_uint64_ = new RepeatedField<uint64>;
+ default_repeated_field_double_ = new RepeatedField<double>;
+ default_repeated_field_float_ = new RepeatedField<float>;
+ default_repeated_field_bool_ = new RepeatedField<bool>;
OnShutdown(&DestroyDefaultRepeatedFields);
}
void RepeatedPrimitiveGenericTypeTraits::DestroyDefaultRepeatedFields() {
- delete cr_default_repeated_field_int32_;
- delete cr_default_repeated_field_int64_;
- delete cr_default_repeated_field_uint32_;
- delete cr_default_repeated_field_uint64_;
- delete cr_default_repeated_field_double_;
- delete cr_default_repeated_field_float_;
- delete cr_default_repeated_field_bool_;
+ delete default_repeated_field_int32_;
+ delete default_repeated_field_int64_;
+ delete default_repeated_field_uint32_;
+ delete default_repeated_field_uint64_;
+ delete default_repeated_field_double_;
+ delete default_repeated_field_float_;
+ delete default_repeated_field_bool_;
}
void RepeatedStringTypeTraits::InitializeDefaultRepeatedFields() {
- cr_default_repeated_field_ = new RepeatedFieldType;
+ default_repeated_field_ = new RepeatedFieldType;
OnShutdown(&DestroyDefaultRepeatedFields);
}
void RepeatedStringTypeTraits::DestroyDefaultRepeatedFields() {
- delete cr_default_repeated_field_;
+ delete default_repeated_field_;
}
void RepeatedMessageGenericTypeTraits::InitializeDefaultRepeatedFields() {
- cr_default_repeated_field_ = new RepeatedFieldType;
+ default_repeated_field_ = new RepeatedFieldType;
OnShutdown(&DestroyDefaultRepeatedFields);
}
void RepeatedMessageGenericTypeTraits::DestroyDefaultRepeatedFields() {
- delete cr_default_repeated_field_;
+ delete default_repeated_field_;
}
+const RepeatedField<int32>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_int32_ = NULL;
+const RepeatedField<int64>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_int64_ = NULL;
+const RepeatedField<uint32>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint32_ = NULL;
+const RepeatedField<uint64>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint64_ = NULL;
+const RepeatedField<double>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_double_ = NULL;
+const RepeatedField<float>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_float_ = NULL;
+const RepeatedField<bool>*
+RepeatedPrimitiveGenericTypeTraits::default_repeated_field_bool_ = NULL;
+const RepeatedStringTypeTraits::RepeatedFieldType*
+RepeatedStringTypeTraits::default_repeated_field_ = NULL;
+const RepeatedMessageGenericTypeTraits::RepeatedFieldType*
+RepeatedMessageGenericTypeTraits::default_repeated_field_ = NULL;
+
} // namespace internal
} // namespace protobuf
} // namespace google

Powered by Google App Engine
This is Rietveld 408576698