ICU-6708 Initialize cache pointers.

X-SVN-Rev: 26454
This commit is contained in:
Michael Ow 2009-07-29 18:58:19 +00:00
parent 2cf1de3050
commit 0b176ddfb3

View file

@ -903,7 +903,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
UResourceBundle *numberPatterns = ures_getByKey(resource, DecimalFormat::fgNumberPatterns, NULL, &status);
NumberingSystem *ns = NULL;
UBool deleteSymbols = TRUE;
UHashtable * cache;
UHashtable * cache = NULL;
int32_t hashKey;
UBool getCache;
@ -978,7 +978,7 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
uhash_setValueDeleter(cache, deleteNumberingSystem);
// set final NumberingSystem_cache value
UHashtable* h;
UHashtable* h = NULL;
UMTX_CHECK(NULL, (UBool)(h != NumberingSystem_cache), getCache);
if (getCache) {
@ -1002,16 +1002,14 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
// Get cached numbering system
if (cache != NULL) {
hashKey = desiredLocale.hashCode();
UMTX_CHECK(NULL, (UBool)(ns == NULL), getCache);
if (getCache) {
umtx_lock(NULL);
ns = (NumberingSystem *)uhash_iget(cache, hashKey);
if (ns == NULL) {
ns = NumberingSystem::createInstance(desiredLocale,status);
uhash_iput(cache, hashKey, (void*)ns, &status);
}
umtx_unlock(NULL);
}
umtx_lock(NULL);
ns = (NumberingSystem *)uhash_iget(cache, hashKey);
if (ns == NULL) {
ns = NumberingSystem::createInstance(desiredLocale,status);
uhash_iput(cache, hashKey, (void*)ns, &status);
}
umtx_unlock(NULL);
}
else {
ns = NumberingSystem::createInstance(desiredLocale,status);