]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/serv.cpp
ICU-62123.0.1.tar.gz
[apple/icu.git] / icuSources / common / serv.cpp
index 2cddcfe65dcdcf3d4b266d273c111b26fb6e4df8..959ab604c68d48629097cb3bef3c34cf7eccfcff 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /**
 *******************************************************************************
-* Copyright (C) 2001-2011, International Business Machines Corporation.
+* Copyright (C) 2001-2014, International Business Machines Corporation.
 * All Rights Reserved.
 *******************************************************************************
 */
@@ -102,7 +104,7 @@ UnicodeString&
 ICUServiceKey::debug(UnicodeString& result) const 
 {
     debugClass(result);
-    result.append(" id: ");
+    result.append((UnicodeString)" id: ");
     result.append(_id);
     return result;
 }
@@ -110,7 +112,7 @@ ICUServiceKey::debug(UnicodeString& result) const
 UnicodeString& 
 ICUServiceKey::debugClass(UnicodeString& result) const 
 {
-    return result.append("ICUServiceKey");
+    return result.append((UnicodeString)"ICUServiceKey");
 }
 #endif
 
@@ -170,17 +172,17 @@ UnicodeString&
 SimpleFactory::debug(UnicodeString& toAppendTo) const 
 {
     debugClass(toAppendTo);
-    toAppendTo.append(" id: ");
+    toAppendTo.append((UnicodeString)" id: ");
     toAppendTo.append(_id);
-    toAppendTo.append(", visible: ");
-    toAppendTo.append(_visible ? "T" : "F");
+    toAppendTo.append((UnicodeString)", visible: ");
+    toAppendTo.append(_visible ? (UnicodeString)"T" : (UnicodeString)"F");
     return toAppendTo;
 }
 
 UnicodeString& 
 SimpleFactory::debugClass(UnicodeString& toAppendTo) const 
 {
-    return toAppendTo.append("SimpleFactory");
+    return toAppendTo.append((UnicodeString)"SimpleFactory");
 }
 #endif
 
@@ -331,7 +333,7 @@ U_CDECL_END
 ******************************************************************
 */
 
-static UMTX lock;
+static UMutex lock = U_MUTEX_INITIALIZER;
 
 ICUService::ICUService()
 : name()
@@ -401,7 +403,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, UErrorCode&
 // reentrantly even without knowing the thread.
 class XMutex : public UMemory {
 public:
-    inline XMutex(UMTX *mutex, UBool reentering) 
+    inline XMutex(UMutex *mutex, UBool reentering) 
         : fMutex(mutex)
         , fActive(!reentering) 
     {
@@ -412,7 +414,7 @@ public:
     }
 
 private:
-    UMTX  *fMutex;
+    UMutex  *fMutex;
     UBool fActive;
 };
 
@@ -545,16 +547,15 @@ outerEnd:
             if (putInCache && cacheResult) {
                 serviceCache->put(result->actualDescriptor, result, status);
                 if (U_FAILURE(status)) {
-                    delete result;
                     return NULL;
                 }
 
                 if (cacheDescriptorList._obj != NULL) {
                     for (int32_t i = cacheDescriptorList._obj->size(); --i >= 0;) {
                         UnicodeString* desc = (UnicodeString*)cacheDescriptorList._obj->elementAt(i);
+
                         serviceCache->put(*desc, result, status);
                         if (U_FAILURE(status)) {
-                            delete result;
                             return NULL;
                         }
 
@@ -619,7 +620,7 @@ ICUService::getVisibleIDs(UVector& result, const UnicodeString* matchID, UErrorC
         if (map != NULL) {
             ICUServiceKey* fallbackKey = createKey(matchID, status);
 
-            for (int32_t pos = -1;;) {
+            for (int32_t pos = UHASH_FIRST;;) {
                 const UHashElement* e = map->nextElement(pos);
                 if (e == NULL) {
                     break;
@@ -761,7 +762,7 @@ ICUService::getDisplayNames(UVector& result,
                 return result;
             }
 
-            int32_t pos = -1;
+            int32_t pos = UHASH_FIRST;
             const UHashElement* entry = NULL;
             while ((entry = m->nextElement(pos)) != NULL) {
                 const UnicodeString* id = (const UnicodeString*)entry->key.pointer;
@@ -788,7 +789,7 @@ ICUService::getDisplayNames(UVector& result,
      * nextElement(pos) will skip the position at pos and begin the iteration
      * at the next position, which in this case will be 0.
      */
-    int32_t pos = -1
+    int32_t pos = UHASH_FIRST
     const UHashElement *entry = NULL;
     while ((entry = dnCache->cache.nextElement(pos)) != NULL) {
         const UnicodeString* id = (const UnicodeString*)entry->value.pointer;