From ee7d6c25c0733ae381c3f0e7b78be142f15e069e Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Wed, 23 Sep 2009 15:41:25 +0000 Subject: [PATCH] ICU-6911 Make one cleanup function for numfmt.cpp X-SVN-Rev: 26677 --- icu4c/source/i18n/numfmt.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/icu4c/source/i18n/numfmt.cpp b/icu4c/source/i18n/numfmt.cpp index 68afff1bd8..a7bebec878 100644 --- a/icu4c/source/i18n/numfmt.cpp +++ b/icu4c/source/i18n/numfmt.cpp @@ -108,6 +108,10 @@ static UHashtable * NumberingSystem_cache = NULL; static UMTX nscacheMutex = NULL; +#if !UCONFIG_NO_SERVICE +static ICULocaleService* gService = NULL; +#endif + /** * Release all static memory held by Number Format. */ @@ -117,12 +121,19 @@ deleteNumberingSystem(void *obj) { delete (NumberingSystem *)obj; } -static UBool U_CALLCONV NSCache_cleanup(void) { +static UBool U_CALLCONV numfmt_cleanup(void) { +#if !UCONFIG_NO_SERVICE + if (gService) { + delete gService; + gService = NULL; + } +#endif if (NumberingSystem_cache) { // delete NumberingSystem_cache; uhash_close(NumberingSystem_cache); NumberingSystem_cache = NULL; - } + } + return TRUE; } U_CDECL_END @@ -508,20 +519,6 @@ NumberFormat::getAvailableLocales(int32_t& count) //------------------------------------------- #if !UCONFIG_NO_SERVICE -static ICULocaleService* gService = NULL; - -/** - * Release all static memory held by numberformat. - */ -U_CDECL_BEGIN -static UBool U_CALLCONV numfmt_cleanup(void) { - if (gService) { - delete gService; - gService = NULL; - } - return TRUE; -} -U_CDECL_END // ------------------------------------- @@ -993,7 +990,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale, umtx_lock(&nscacheMutex); NumberingSystem_cache = h = cache; cache = NULL; - ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, NSCache_cleanup); + ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, numfmt_cleanup); umtx_unlock(&nscacheMutex); }