#if !UCONFIG_NO_SERVICE
struct CReg;
-static UMutex *gCRegLock() {
- static UMutex *m = STATIC_NEW(UMutex);
- return m;
-}
+static UMutex gCRegLock;
static CReg* gCRegHead = 0;
struct CReg : public icu::UMemory {
if (status && U_SUCCESS(*status) && _iso && _id) {
CReg* n = new CReg(_iso, _id);
if (n) {
- umtx_lock(gCRegLock());
+ umtx_lock(&gCRegLock);
if (!gCRegHead) {
/* register for the first time */
ucln_common_registerCleanup(UCLN_COMMON_CURRENCY, currency_cleanup);
}
n->next = gCRegHead;
gCRegHead = n;
- umtx_unlock(gCRegLock());
+ umtx_unlock(&gCRegLock);
return n;
}
*status = U_MEMORY_ALLOCATION_ERROR;
static UBool unreg(UCurrRegistryKey key) {
UBool found = FALSE;
- umtx_lock(gCRegLock());
+ umtx_lock(&gCRegLock);
CReg** p = &gCRegHead;
while (*p) {
p = &((*p)->next);
}
- umtx_unlock(gCRegLock());
+ umtx_unlock(&gCRegLock);
return found;
}
static const UChar* get(const char* id) {
const UChar* result = NULL;
- umtx_lock(gCRegLock());
+ umtx_lock(&gCRegLock);
CReg* p = gCRegHead;
/* register cleanup of the mutex */
}
p = p->next;
}
- umtx_unlock(gCRegLock());
+ umtx_unlock(&gCRegLock);
return result;
}
// We no longer support choice format data in names. Data should not contain
// choice patterns.
- *isChoiceFormat = FALSE;
+ if (isChoiceFormat != NULL) {
+ *isChoiceFormat = FALSE;
+ }
if (U_SUCCESS(ec2)) {
U_ASSERT(s != NULL);
return s;
// It is a simple round-robin replacement strategy.
static int8_t currentCacheEntryIndex = 0;
-static UMutex *gCurrencyCacheMutex() {
- static UMutex *m = STATIC_NEW(UMutex);
- return m;
-}
+static UMutex gCurrencyCacheMutex;
// Cache deletion
static void
CurrencyNameStruct* currencySymbols = NULL;
CurrencyNameCacheEntry* cacheEntry = NULL;
- umtx_lock(gCurrencyCacheMutex());
+ umtx_lock(&gCurrencyCacheMutex);
// in order to handle racing correctly,
// not putting 'search' in a separate function.
int8_t found = -1;
cacheEntry = currCache[found];
++(cacheEntry->refCount);
}
- umtx_unlock(gCurrencyCacheMutex());
+ umtx_unlock(&gCurrencyCacheMutex);
if (found == -1) {
collectCurrencyNames(locale, ¤cyNames, &total_currency_name_count, ¤cySymbols, &total_currency_symbol_count, ec);
if (U_FAILURE(ec)) {
return NULL;
}
- umtx_lock(gCurrencyCacheMutex());
+ umtx_lock(&gCurrencyCacheMutex);
// check again.
for (int8_t i = 0; i < CURRENCY_NAME_CACHE_NUM; ++i) {
if (currCache[i]!= NULL &&
cacheEntry = currCache[found];
++(cacheEntry->refCount);
}
- umtx_unlock(gCurrencyCacheMutex());
+ umtx_unlock(&gCurrencyCacheMutex);
}
return cacheEntry;
}
static void releaseCacheEntry(CurrencyNameCacheEntry* cacheEntry) {
- umtx_lock(gCurrencyCacheMutex());
+ umtx_lock(&gCurrencyCacheMutex);
--(cacheEntry->refCount);
if (cacheEntry->refCount == 0) { // remove
deleteCacheEntry(cacheEntry);
}
- umtx_unlock(gCurrencyCacheMutex());
+ umtx_unlock(&gCurrencyCacheMutex);
}
U_CAPI void
{
U_NAMESPACE_USE
- UBool isChoiceFormat;
int32_t len;
const UChar* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME,
- &isChoiceFormat, &len, &ec);
+ nullptr /* isChoiceFormat */, &len, &ec);
if (U_SUCCESS(ec)) {
result.setTo(currname, len);
}