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

Unified Diff: third_party/protobuf/src/google/protobuf/stubs/structurally_valid.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/stubs/structurally_valid.cc
diff --git a/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc b/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc
index 30786e396d01aa247aa02b1cb0fe586a7c61aad7..d79a6ee45007c99d7b2059d50b1ff37485a3138d 100644
--- a/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc
+++ b/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc
@@ -511,10 +511,21 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st,
// UTF-8 strings. Since UTF-8 validation is only used for debugging
// anyway, we simply always return success if initialization hasn't
// occurred yet.
-extern bool cr_module_initialized_;
+namespace {
+
+bool module_initialized_ = false;
+
+struct InitDetector {
+ InitDetector() {
+ module_initialized_ = true;
+ }
+};
+InitDetector init_detector;
+
+} // namespace
bool IsStructurallyValidUTF8(const char* buf, int len) {
- if (!cr_module_initialized_) return true;
+ if (!module_initialized_) return true;
int bytes_consumed = 0;
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,
@@ -523,7 +534,7 @@ bool IsStructurallyValidUTF8(const char* buf, int len) {
}
int UTF8SpnStructurallyValid(const StringPiece& str) {
- if (!cr_module_initialized_) return str.size();
+ if (!module_initialized_) return str.size();
int bytes_consumed = 0;
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/common.cc ('k') | third_party/protobuf/src/google/protobuf/stubs/strutil.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698