From a97cfb01b917125fdb9705cf79786188cebb6e2e Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Mon, 22 Apr 2019 12:54:14 -0700 Subject: [PATCH] ICU-20570 UInitOnce instances, add explicit initialization where it was missing. --- icu4c/source/common/brkiter.cpp | 2 +- icu4c/source/common/characterproperties.cpp | 4 ++-- icu4c/source/common/normalizer2impl.h | 6 ++---- icu4c/source/common/uresbund.cpp | 2 +- icu4c/source/common/usprep.cpp | 2 +- icu4c/source/i18n/buddhcal.cpp | 2 +- icu4c/source/i18n/coll.cpp | 2 +- icu4c/source/i18n/csdetect.cpp | 2 +- icu4c/source/i18n/olsontz.h | 2 +- 9 files changed, 11 insertions(+), 13 deletions(-) diff --git a/icu4c/source/common/brkiter.cpp b/icu4c/source/common/brkiter.cpp index 52e5c7cf92..3d1366a668 100644 --- a/icu4c/source/common/brkiter.cpp +++ b/icu4c/source/common/brkiter.cpp @@ -277,7 +277,7 @@ ICUBreakIteratorService::~ICUBreakIteratorService() {} // defined in ucln_cmn.h U_NAMESPACE_END -static icu::UInitOnce gInitOnceBrkiter; +static icu::UInitOnce gInitOnceBrkiter = U_INITONCE_INITIALIZER; static icu::ICULocaleService* gService = NULL; diff --git a/icu4c/source/common/characterproperties.cpp b/icu4c/source/common/characterproperties.cpp index 5a57364375..030cca9771 100644 --- a/icu4c/source/common/characterproperties.cpp +++ b/icu4c/source/common/characterproperties.cpp @@ -38,8 +38,8 @@ UBool U_CALLCONV characterproperties_cleanup(); constexpr int32_t NUM_INCLUSIONS = UPROPS_SRC_COUNT + UCHAR_INT_LIMIT - UCHAR_INT_START; struct Inclusion { - UnicodeSet *fSet; - UInitOnce fInitOnce; + UnicodeSet *fSet = nullptr; + UInitOnce fInitOnce = U_INITONCE_INITIALIZER; }; Inclusion gInclusions[NUM_INCLUSIONS]; // cached getInclusions() diff --git a/icu4c/source/common/normalizer2impl.h b/icu4c/source/common/normalizer2impl.h index 7ecdef6d9c..cf3015ea88 100644 --- a/icu4c/source/common/normalizer2impl.h +++ b/icu4c/source/common/normalizer2impl.h @@ -245,9 +245,7 @@ private: */ class U_COMMON_API Normalizer2Impl : public UObject { public: - Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { - fCanonIterDataInitOnce.reset(); - } + Normalizer2Impl() : normTrie(NULL), fCanonIterData(NULL) { } virtual ~Normalizer2Impl(); void init(const int32_t *inIndexes, const UCPTrie *inTrie, @@ -723,7 +721,7 @@ private: const uint16_t *extraData; // mappings and/or compositions for yesYes, yesNo & noNo characters const uint8_t *smallFCD; // [0x100] one bit per 32 BMP code points, set if any FCD!=0 - UInitOnce fCanonIterDataInitOnce; + UInitOnce fCanonIterDataInitOnce = U_INITONCE_INITIALIZER; CanonIterData *fCanonIterData; }; diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index af6d1a1f7c..483f5ff5f4 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -47,7 +47,7 @@ TODO: This cache should probably be removed when the deprecated code is completely removed. */ static UHashtable *cache = NULL; -static icu::UInitOnce gCacheInitOnce; +static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; static UMutex *resbMutex() { static UMutex m = U_MUTEX_INITIALIZER; diff --git a/icu4c/source/common/usprep.cpp b/icu4c/source/common/usprep.cpp index a05fae1c68..eb2b2a17af 100644 --- a/icu4c/source/common/usprep.cpp +++ b/icu4c/source/common/usprep.cpp @@ -45,7 +45,7 @@ U_CDECL_BEGIN Static cache for already opened StringPrep profiles */ static UHashtable *SHARED_DATA_HASHTABLE = NULL; -static icu::UInitOnce gSharedDataInitOnce; +static icu::UInitOnce gSharedDataInitOnce = U_INITONCE_INITIALIZER; static UMutex *usprepMutex() { static UMutex m = U_MUTEX_INITIALIZER; diff --git a/icu4c/source/i18n/buddhcal.cpp b/icu4c/source/i18n/buddhcal.cpp index 6fac7a80c7..2a36bd38cc 100644 --- a/icu4c/source/i18n/buddhcal.cpp +++ b/icu4c/source/i18n/buddhcal.cpp @@ -133,7 +133,7 @@ void BuddhistCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& stat */ static UDate gSystemDefaultCenturyStart = DBL_MIN; static int32_t gSystemDefaultCenturyStartYear = -1; -static icu::UInitOnce gBCInitOnce; +static icu::UInitOnce gBCInitOnce = U_INITONCE_INITIALIZER; UBool BuddhistCalendar::haveDefaultCentury() const diff --git a/icu4c/source/i18n/coll.cpp b/icu4c/source/i18n/coll.cpp index 2298f60a24..7b87b41dff 100644 --- a/icu4c/source/i18n/coll.cpp +++ b/icu4c/source/i18n/coll.cpp @@ -67,7 +67,7 @@ static int32_t availableLocaleListCount; static icu::ICULocaleService* gService = NULL; static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER; #endif -static icu::UInitOnce gAvailableLocaleListInitOnce; +static icu::UInitOnce gAvailableLocaleListInitOnce = U_INITONCE_INITIALIZER; /** * Release all static memory held by collator. diff --git a/icu4c/source/i18n/csdetect.cpp b/icu4c/source/i18n/csdetect.cpp index 2436760a9b..babb308430 100644 --- a/icu4c/source/i18n/csdetect.cpp +++ b/icu4c/source/i18n/csdetect.cpp @@ -47,7 +47,7 @@ struct CSRecognizerInfo : public UMemory { U_NAMESPACE_END static icu::CSRecognizerInfo **fCSRecognizers = NULL; -static icu::UInitOnce gCSRecognizersInitOnce; +static icu::UInitOnce gCSRecognizersInitOnce = U_INITONCE_INITIALIZER; static int32_t fCSRecognizers_size = 0; U_CDECL_BEGIN diff --git a/icu4c/source/i18n/olsontz.h b/icu4c/source/i18n/olsontz.h index ccc0cf9f96..7bec8e070a 100644 --- a/icu4c/source/i18n/olsontz.h +++ b/icu4c/source/i18n/olsontz.h @@ -398,7 +398,7 @@ private: TimeArrayTimeZoneRule **historicRules; int16_t historicRuleCount; SimpleTimeZone *finalZoneWithStartYear; // hack - UInitOnce transitionRulesInitOnce; + UInitOnce transitionRulesInitOnce = U_INITONCE_INITIALIZER; }; inline int16_t