void Region::cleanupRegionData() { for (int32_t i = 0 ; i < URGN_LIMIT ; i++ ) { if ( availableRegions[i] ) { delete availableRegions[i]; } } if (regionAliases) { uhash_close(regionAliases); } if (numericCodeMap) { uhash_close(numericCodeMap); } if (regionIDMap) { uhash_close(regionIDMap); } if (allRegions) { allRegions->removeAllElements(); // Don't need the temporary list anymore. delete allRegions; allRegions = NULL; } regionAliases = numericCodeMap = regionIDMap = NULL; gRegionDataInitOnce.reset(); }
/** * Cleanup callback func */ static UBool U_CALLCONV zoneMeta_cleanup(void) { umtx_destroy(&gZoneMetaLock); if (gCanonicalMap != NULL) { uhash_close(gCanonicalMap); gCanonicalMap = NULL; } gCanonicalMapInitialized = FALSE; if (gOlsonToMeta != NULL) { uhash_close(gOlsonToMeta); gOlsonToMeta = NULL; } gOlsonToMetaInitialized = FALSE; if (gMetaToOlson != NULL) { uhash_close(gMetaToOlson); gMetaToOlson = NULL; } gMetaToOlsonInitialized = FALSE; freeUStringTable(); return TRUE; }
U_CDECL_BEGIN /** * Cleanup callback func */ static UBool U_CALLCONV zoneMeta_cleanup(void) { if (gCanonicalIDCache != NULL) { uhash_close(gCanonicalIDCache); gCanonicalIDCache = NULL; } gCanonicalIDCacheInitialized = FALSE; if (gOlsonToMeta != NULL) { uhash_close(gOlsonToMeta); gOlsonToMeta = NULL; } gOlsonToMetaInitialized = FALSE; if (gMetaZoneIDTable != NULL) { uhash_close(gMetaZoneIDTable); } // delete after closing gMetaZoneIDTable, because it holds // value objects held by the hashtable delete gMetaZoneIDs; gMetaZoneIDsInitialized = FALSE; delete gSingleZoneCountries; delete gMultiZonesCountries; gCountryInfoVectorsInitialized = FALSE; return TRUE; }
static void U_CALLCONV initAvailableMetaZoneIDs () { U_ASSERT(gMetaZoneIDs == NULL); U_ASSERT(gMetaZoneIDTable == NULL); ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup); UErrorCode status = U_ZERO_ERROR; gMetaZoneIDTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status); if (U_FAILURE(status) || gMetaZoneIDTable == NULL) { gMetaZoneIDTable = NULL; return; } uhash_setKeyDeleter(gMetaZoneIDTable, uprv_deleteUObject); // No valueDeleter, because the vector maintain the value objects gMetaZoneIDs = new UVector(NULL, uhash_compareUChars, status); if (U_FAILURE(status) || gMetaZoneIDs == NULL) { gMetaZoneIDs = NULL; uhash_close(gMetaZoneIDTable); gMetaZoneIDTable = NULL; return; } gMetaZoneIDs->setDeleter(uprv_free); UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status); UResourceBundle *bundle = ures_getByKey(rb, gMapTimezonesTag, NULL, &status); UResourceBundle res; ures_initStackObject(&res); while (U_SUCCESS(status) && ures_hasNext(bundle)) { ures_getNextResource(bundle, &res, &status); if (U_FAILURE(status)) { break; } const char *mzID = ures_getKey(&res); int32_t len = uprv_strlen(mzID); UChar *uMzID = (UChar*)uprv_malloc(sizeof(UChar) * (len + 1)); if (uMzID == NULL) { status = U_MEMORY_ALLOCATION_ERROR; break; } u_charsToUChars(mzID, uMzID, len); uMzID[len] = 0; UnicodeString *usMzID = new UnicodeString(uMzID); if (uhash_get(gMetaZoneIDTable, usMzID) == NULL) { gMetaZoneIDs->addElement((void *)uMzID, status); uhash_put(gMetaZoneIDTable, (void *)usMzID, (void *)uMzID, &status); } else { uprv_free(uMzID); delete usMzID; } } ures_close(&res); ures_close(bundle); ures_close(rb); if (U_FAILURE(status)) { uhash_close(gMetaZoneIDTable); delete gMetaZoneIDs; gMetaZoneIDTable = NULL; gMetaZoneIDs = NULL; } }
void TZGNCore::cleanup() { if (fLocaleDisplayNames != NULL) { delete fLocaleDisplayNames; } if (fTimeZoneNames != NULL) { delete fTimeZoneNames; } uhash_close(fLocationNamesMap); uhash_close(fPartialLocationNamesMap); }
void TimeZoneNamesImpl::cleanup() { if (fZoneStrings != NULL) { ures_close(fZoneStrings); fZoneStrings = NULL; } if (fMZNamesMap != NULL) { uhash_close(fMZNamesMap); fMZNamesMap = NULL; } if (fTZNamesMap != NULL) { uhash_close(fTZNamesMap); fTZNamesMap = NULL; } }
ConfusabledataBuilder::~ConfusabledataBuilder() { uprv_free(fInput); uregex_close(fParseLine); uregex_close(fParseHexNum); uhash_close(fSLTable); uhash_close(fSATable); uhash_close(fMLTable); uhash_close(fMATable); delete fKeySet; delete fKeyVec; delete fStringTable; delete fStringLengthsTable; delete fValueVec; delete stringPool; }
U_CDECL_END /** Initializes the cache for resources */ static void initCache(UErrorCode * status) { UBool makeCache; UMTX_CHECK(&usprepMutex, (SHARED_DATA_HASHTABLE == NULL), makeCache); if (makeCache) { UHashtable * newCache = uhash_open(hashEntry, compareEntries, NULL, status); if (U_SUCCESS(*status)) { umtx_lock(&usprepMutex); if (SHARED_DATA_HASHTABLE == NULL) { SHARED_DATA_HASHTABLE = newCache; ucln_common_registerCleanup(UCLN_COMMON_USPREP, usprep_cleanup); newCache = NULL; } umtx_unlock(&usprepMutex); } if (newCache != NULL) { uhash_close(newCache); } } }
static void hashIChars(void) { static const char which[] = "which"; static const char WHICH2[] = "WHICH"; static const char where[] = "where"; UErrorCode status = U_ZERO_ERROR; UHashtable *hash; hash = uhash_open(uhash_hashIChars, uhash_compareIChars, NULL, &status); if (U_FAILURE(status)) { log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n", u_errorName(status), hash); return; } if (hash == NULL) { log_err("FAIL: uhash_open returned NULL\n"); return; } log_verbose("Ok: uhash_open returned 0x%08X\n", hash); _put(hash, which, 1, 0); _put(hash, WHICH2, 2, 1); _put(hash, where, 3, 0); if(uhash_count(hash) != 2){ log_err("FAIL: uhas_count() failed. Expected: 1, Got: %d\n", uhash_count(hash)); } _remove(hash, which, 2); uhash_close(hash); }
CollDataCache::~CollDataCache() { umtx_lock(&lock); uhash_close(cache); cache = NULL; umtx_unlock(&lock); }
/* udata_getCacheHashTable() * Get the hash table used to store the data cache entries. * Lazy create it if it doesn't yet exist. */ static UHashtable *udata_getHashTable() { UErrorCode err = U_ZERO_ERROR; UBool cacheIsInitialized; UHashtable *tHT = NULL; UMTX_CHECK(NULL, (gCommonDataCache != NULL), cacheIsInitialized); if (cacheIsInitialized) { return gCommonDataCache; } tHT = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &err); /* Check for null pointer. */ if (tHT == NULL) { return NULL; /* TODO: Handle this error better. */ } uhash_setValueDeleter(tHT, DataCacheElement_deleter); umtx_lock(NULL); if (gCommonDataCache == NULL) { gCommonDataCache = tHT; tHT = NULL; ucln_common_registerCleanup(UCLN_COMMON_UDATA, udata_cleanup); } umtx_unlock(NULL); if (tHT != NULL) { uhash_close(tHT); } if (U_FAILURE(err)) { return NULL; /* TODO: handle this error better. */ } return gCommonDataCache; }
//-------------------------------------------------------------------------- // // zap Delete everything owned by this RegexPattern. // //-------------------------------------------------------------------------- void RegexPattern::zap() { delete fCompiledPat; fCompiledPat = NULL; int i; for (i=1; i<fSets->size(); i++) { UnicodeSet *s; s = (UnicodeSet *)fSets->elementAt(i); if (s != NULL) { delete s; } } delete fSets; fSets = NULL; delete[] fSets8; fSets8 = NULL; delete fGroupMap; fGroupMap = NULL; delete fInitialChars; fInitialChars = NULL; delete fInitialChars8; fInitialChars8 = NULL; if (fPattern != NULL) { utext_close(fPattern); fPattern = NULL; } if (fPatternString != NULL) { delete fPatternString; fPatternString = NULL; } uhash_close(fNamedCaptureMap); fNamedCaptureMap = NULL; }
static void U_CALLCONV uloc_deleteKeyDataEntry(void* obj) { LocExtKeyData* keyData = (LocExtKeyData*)obj; if (keyData->typeMap != NULL) { uhash_close(keyData->typeMap); } uprv_free(keyData); }
IdentifierInfo::~IdentifierInfo() { delete fIdentifier; delete fRequiredScripts; uhash_close(fScriptSetSet); delete fCommonAmongAlternates; delete fNumerics; delete fIdentifierProfile; }
SPUStringPool::~SPUStringPool() { int i; for (i=fVec->size()-1; i>=0; i--) { SPUString *s = static_cast<SPUString *>(fVec->elementAt(i)); delete s; } delete fVec; uhash_close(fHash); }
static UBool U_CALLCONV usprep_cleanup(void){ if (SHARED_DATA_HASHTABLE != NULL) { usprep_internal_flushCache(TRUE); if (SHARED_DATA_HASHTABLE != NULL && uhash_count(SHARED_DATA_HASHTABLE) == 0) { uhash_close(SHARED_DATA_HASHTABLE); SHARED_DATA_HASHTABLE = NULL; } } gSharedDataInitOnce.reset(); return (SHARED_DATA_HASHTABLE == NULL); }
U_NAMESPACE_END U_CDECL_BEGIN static UBool U_CALLCONV cdf_cleanup(void) { if (gCompactDecimalData != NULL) { uhash_close(gCompactDecimalData); gCompactDecimalData = NULL; } return TRUE; }
U_CDECL_BEGIN static UBool U_CALLCONV gender_cleanup(void) { if (gGenderInfoCache != NULL) { uhash_close(gGenderInfoCache); gGenderInfoCache = NULL; delete [] gObjs; } gGenderInitOnce.reset(); return TRUE; }
void Region::cleanupRegionData() { for (int32_t i = 0 ; i < URGN_LIMIT ; i++ ) { if ( availableRegions[i] ) { delete availableRegions[i]; } } if (regionAliases) { uhash_close(regionAliases); } if (numericCodeMap) { uhash_close(numericCodeMap); } if (regionIDMap) { uhash_close(regionIDMap); } }
static UBool U_CALLCONV uprv_loaded_normalizer2_cleanup() { delete nfkcSingleton; nfkcSingleton = NULL; delete nfkc_cfSingleton; nfkc_cfSingleton = NULL; uhash_close(cache); cache=NULL; nfkcInitOnce.reset(); nfkc_cfInitOnce.reset(); return TRUE; }
UnifiedCache::~UnifiedCache() { // Try our best to clean up first. flush(); { // Now all that should be left in the cache are entries that refer to // each other and entries with hard references from outside the cache. // Nothing we can do about these so proceed to wipe out the cache. Mutex lock(&gCacheMutex); _flush(TRUE); } uhash_close(fHashtable); }
AlphabeticIndex::~AlphabeticIndex() { uhash_close(alreadyIn_); delete bucketList_; delete collator_; delete collatorPrimaryOnly_; delete firstScriptCharacters_; delete labels_; delete inputRecords_; delete noDistinctSorting_; delete notAlphabetic_; delete initialLabels_; }
static void TestBasic(void) { const char one[4] = {0x6F, 0x6E, 0x65, 0}; /* "one" */ const char one2[4] = {0x6F, 0x6E, 0x65, 0}; /* Get around compiler optimizations */ const char two[4] = {0x74, 0x77, 0x6F, 0}; /* "two" */ const char three[6] = {0x74, 0x68, 0x72, 0x65, 0x65, 0}; /* "three" */ const char omega[6] = {0x6F, 0x6D, 0x65, 0x67, 0x61, 0}; /* "omega" */ UErrorCode status = U_ZERO_ERROR; UHashtable *hash; hash = uhash_open(hashChars, isEqualChars, &status); if (U_FAILURE(status)) { log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n", u_errorName(status), hash); return; } if (hash == NULL) { log_err("FAIL: uhash_open returned NULL\n"); return; } log_verbose("Ok: uhash_open returned 0x%08X\n", hash); _put(hash, one, 1, 0); _put(hash, omega, 24, 0); _put(hash, two, 2, 0); _put(hash, three, 3, 0); _put(hash, one, -1, 1); _put(hash, two, -2, 2); _put(hash, omega, 48, 24); _put(hash, one, 100, -1); _get(hash, three, 3); _remove(hash, two, -2); _get(hash, two, 0); _get(hash, one, 100); _put(hash, two, 200, 0); _get(hash, omega, 48); _get(hash, two, 200); if(_compareChars((void*)one, (void*)three) == TRUE || _compareChars((void*)one, (void*)one2) != TRUE || _compareChars((void*)one, (void*)one) != TRUE || _compareChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareChars failed\n"); } if(_compareIChars((void*)one, (void*)three) == TRUE || _compareIChars((void*)one, (void*)one) != TRUE || _compareIChars((void*)one, (void*)one2) != TRUE || _compareIChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareIChars failed\n"); } uhash_close(hash); }
ZNStringPool::~ZNStringPool() { if (fHash != NULL) { uhash_close(fHash); fHash = NULL; } while (fChunks != NULL) { ZNStringPoolChunk *nextChunk = fChunks->fNext; delete fChunks; fChunks = nextChunk; } }
U_CDECL_BEGIN /** * Cleanup callback func */ static UBool U_CALLCONV tzgnCore_cleanup(void) { if (gTZGNCoreCache != NULL) { uhash_close(gTZGNCoreCache); gTZGNCoreCache = NULL; } gTZGNCoreCacheInitialized = FALSE; return TRUE; }
U_CDECL_BEGIN /** * Cleanup callback func */ static UBool U_CALLCONV timeZoneNames_cleanup(void) { if (gTimeZoneNamesCache != NULL) { uhash_close(gTimeZoneNamesCache); gTimeZoneNamesCache = NULL; } gTimeZoneNamesCacheInitialized = FALSE; return TRUE; }
/* Not supported API. Marked U_CAPI only for use by test programs. */ U_CFUNC UBool U_EXPORT2 ucnv_cleanup(void) { if (SHARED_DATA_HASHTABLE != NULL) { ucnv_flushCache(); if (SHARED_DATA_HASHTABLE != NULL && uhash_count(SHARED_DATA_HASHTABLE) == 0) { uhash_close(SHARED_DATA_HASHTABLE); SHARED_DATA_HASHTABLE = NULL; } } umtx_destroy(&cnvCacheMutex); /* Don't worry about destroying the mutex even */ /* if the hash table still exists. The mutex */ /* will lazily re-init itself if needed. */ return (SHARED_DATA_HASHTABLE == NULL); }
static UBool U_CALLCONV usprep_cleanup(void){ if (SHARED_DATA_HASHTABLE != NULL) { usprep_internal_flushCache(TRUE); if (SHARED_DATA_HASHTABLE != NULL && uhash_count(SHARED_DATA_HASHTABLE) == 0) { uhash_close(SHARED_DATA_HASHTABLE); SHARED_DATA_HASHTABLE = NULL; } } umtx_destroy(&usprepMutex); /* Don't worry about destroying the mutex even */ /* if the hash table still exists. The mutex */ /* will lazily re-init itself if needed. */ return (SHARED_DATA_HASHTABLE == NULL); }
static UBool U_CALLCONV locale_cleanup(void) { U_NAMESPACE_USE delete [] gLocaleCache; gLocaleCache = NULL; gLocaleCacheInitOnce.reset(); if (gDefaultLocalesHashT) { uhash_close(gDefaultLocalesHashT); // Automatically deletes all elements, using deleter func. gDefaultLocalesHashT = NULL; } gDefaultLocale = NULL; return TRUE; }
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; }