return results;
}
-static UMutex gLock = U_MUTEX_INITIALIZER;
+static UMutex *gLock() {
+ static UMutex *m = STATIC_NEW(UMutex);
+ return m;
+}
class TZGNCore : public UMemory {
public:
// target region
const char* region = fLocale.getCountry();
- int32_t regionLen = uprv_strlen(region);
+ int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
if (regionLen == 0) {
char loc[ULOC_FULLNAME_CAPACITY];
uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
const UChar *locname = NULL;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
- umtx_lock(&gLock);
+ umtx_lock(gLock());
{
locname = nonConstThis->getGenericLocationName(tzCanonicalID);
}
- umtx_unlock(&gLock);
+ umtx_unlock(gLock());
if (locname == NULL) {
name.setToBogus();
const UChar *uplname = NULL;
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
- umtx_lock(&gLock);
+ umtx_lock(gLock());
{
uplname = nonConstThis->getPartialLocationName(tzCanonicalID, mzID, isLong, mzDisplayName);
}
- umtx_unlock(&gLock);
+ umtx_unlock(gLock());
if (uplname == NULL) {
name.setToBogus();
TZGNCore *nonConstThis = const_cast<TZGNCore *>(this);
- umtx_lock(&gLock);
+ umtx_lock(gLock());
{
fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status);
}
- umtx_unlock(&gLock);
+ umtx_unlock(gLock());
if (U_FAILURE(status)) {
return NULL;
// All names are not yet loaded into the local trie.
// Load all available names into the trie. This could be very heavy.
- umtx_lock(&gLock);
+ umtx_lock(gLock());
{
if (!fGNamesTrieFullyLoaded) {
StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
}
}
}
- umtx_unlock(&gLock);
+ umtx_unlock(gLock());
if (U_FAILURE(status)) {
return NULL;
}
- umtx_lock(&gLock);
+ umtx_lock(gLock());
{
// now try it again
fGNamesTrie.search(text, start, (TextTrieMapSearchResultHandler *)&handler, status);
}
- umtx_unlock(&gLock);
+ umtx_unlock(gLock());
results = handler.getMatches(maxLen);
if (results != NULL && maxLen > 0) {
} TZGNCoreRef;
// TZGNCore object cache handling
-static UMutex gTZGNLock = U_MUTEX_INITIALIZER;
+static UMutex *gTZGNLock() {
+ static UMutex *m = STATIC_NEW(UMutex);
+ return m;
+}
static UHashtable *gTZGNCoreCache = NULL;
static UBool gTZGNCoreCacheInitialized = FALSE;
}
TimeZoneGenericNames::~TimeZoneGenericNames() {
- umtx_lock(&gTZGNLock);
+ umtx_lock(gTZGNLock());
{
U_ASSERT(fRef->refCount > 0);
// Just decrement the reference count
fRef->refCount--;
}
- umtx_unlock(&gTZGNLock);
+ umtx_unlock(gTZGNLock());
}
TimeZoneGenericNames*
TZGNCoreRef *cacheEntry = NULL;
{
- Mutex lock(&gTZGNLock);
+ Mutex lock(gTZGNLock());
if (!gTZGNCoreCacheInitialized) {
// Create empty hashtable
TimeZoneGenericNames::clone() const {
TimeZoneGenericNames* other = new TimeZoneGenericNames();
if (other) {
- umtx_lock(&gTZGNLock);
+ umtx_lock(gTZGNLock());
{
// Just increments the reference count
fRef->refCount++;
other->fRef = fRef;
}
- umtx_unlock(&gTZGNLock);
+ umtx_unlock(gTZGNLock());
}
return other;
}