]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/locavailable.cpp
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / common / locavailable.cpp
index 8782d0c77e667878205d06e6d45a61b735b37549..5f06aff3a2dcc4b84d8338b77df492febb506da1 100644 (file)
@@ -125,8 +125,6 @@ static UBool U_CALLCONV uloc_cleanup(void) {
 //   via the initOnce mechanism.
 
 static void U_CALLCONV loadInstalledLocales() {
-    UResourceBundle *indexLocale = NULL;
-    UResourceBundle installed;
     UErrorCode status = U_ZERO_ERROR;
     int32_t i = 0;
     int32_t localeCount;
@@ -135,25 +133,25 @@ static void U_CALLCONV loadInstalledLocales() {
     U_ASSERT(_installedLocalesCount == 0);
 
     _installedLocalesCount = 0;
-    ures_initStackObject(&installed);
-    indexLocale = ures_openDirect(NULL, _kIndexLocaleName, &status);
-    ures_getByKey(indexLocale, _kIndexTag, &installed, &status);
-    
+
+    icu::LocalUResourceBundlePointer indexLocale(ures_openDirect(NULL, _kIndexLocaleName, &status));
+    icu::StackUResourceBundle installed;
+
+    ures_getByKey(indexLocale.getAlias(), _kIndexTag, installed.getAlias(), &status);
+
     if(U_SUCCESS(status)) {
-        localeCount = ures_getSize(&installed);
+        localeCount = ures_getSize(installed.getAlias());
         _installedLocales = (char **) uprv_malloc(sizeof(char*) * (localeCount+1));
         if (_installedLocales != NULL) {
-            ures_resetIterator(&installed);
-            while(ures_hasNext(&installed)) {
-                ures_getNextString(&installed, NULL, (const char **)&_installedLocales[i++], &status);
+            ures_resetIterator(installed.getAlias());
+            while(ures_hasNext(installed.getAlias())) {
+                ures_getNextString(installed.getAlias(), NULL, (const char **)&_installedLocales[i++], &status);
             }
             _installedLocales[i] = NULL;
             _installedLocalesCount = localeCount;
             ucln_common_registerCleanup(UCLN_COMMON_ULOC, uloc_cleanup);
         }
     }
-    ures_close(&installed);
-    ures_close(indexLocale);
 }
 
 static void _load_installedLocales()