Fix the misused argument for collection.
authorHokwon Song <hokwon.song@samsung.com>
Wed, 5 Jun 2013 06:18:47 +0000 (15:18 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Wed, 5 Jun 2013 06:18:47 +0000 (15:18 +0900)
Change-Id: Iea1fe95c84b53012f28951cfeed5decb732e9502
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
src/locales/FLclLocaleManager.cpp
src/locales/FLcl_CurrencyImpl.cpp
src/locales/FLcl_DateTimeSymbolsImpl.cpp
src/locales/FLcl_LocaleData.cpp

index 8b16c78..b888f7d 100644 (file)
@@ -97,7 +97,7 @@ LocaleManager::GetAvailableTimeZonesN(void) const
        {
                std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
                SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-               result r = pArrayList->Add(*(pTz.get()));
+               result r = pArrayList->Add(pTz.get());
                SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
                pTz.release();
        }
@@ -120,7 +120,7 @@ LocaleManager::GetAvailableTimeZonesN(int rawOffset) const
        {
                std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
                SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-               result r = pArrayList->Add(*(pTz.get()));
+               result r = pArrayList->Add(pTz.get());
                SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
                pTz.release();
        }
index 9f76a42..5f46d32 100644 (file)
@@ -121,7 +121,7 @@ _CurrencyImpl::GetAvailableCurrenciesN(void)
                        pCurr->__currencyCodeSymbol = currCode + "_" + currSymbol;
                        if (!pNewList->Contains(*(pCurr.get())))
                        {
-                               result r = pNewList->Add(*(pCurr.get()));
+                               result r = pNewList->Add(pCurr.get());
                                SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "Itis fail to make the currency list.");
                                pCurr.release();
                        }
index 7e6cb01..319576c 100644 (file)
@@ -441,7 +441,7 @@ _DateTimeSymbolsImpl::CloneArrayListN(const IList* pList) const
                std::unique_ptr< String > pClonedString(new (std::nothrow) String(*(static_cast<const String*>(pList->GetAt(i)))));
                SysTryReturn(NID_LCL, pClonedString, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               r = pClonedArrayList->Add(*pClonedString);
+               r = pClonedArrayList->Add(pClonedString.get());
                SysTryReturn(NID_LCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
 
                pClonedString.release();
@@ -486,7 +486,7 @@ _DateTimeSymbolsImpl::CloneMultiHashMapN(const Tizen::Base::Collection::IMultiMa
                        std::unique_ptr< String > pTimeZoneName(new (std::nothrow) String(*(static_cast<String*> (pValueEnum->GetCurrent()))));
                        if (pTimeZoneName)
                        {
-                               r = pClonedMultiHashMap->Add(*pMapKey, *pTimeZoneName);
+                               r = pClonedMultiHashMap->Add(pMapKey.get(), pTimeZoneName.get());
                                if (IsFailed(r))
                                {
                                        pClonedMultiHashMap->Remove(*pMapKey,true);
@@ -529,7 +529,7 @@ _DateTimeSymbolsImpl::SetList(Tizen::Base::Collection::ArrayList* pArrayList, in
                        pListStr.reset(new (std::nothrow) String(token));
                        SysTryReturnResult(NID_LCL, pListStr, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-                       r = pTmpArrayList->Add(*pListStr);
+                       r = pTmpArrayList->Add(pListStr.get());
                        SysTryReturnResult(NID_LCL, r == E_SUCCESS, r, "Failed to add value to array list.");
 
                        pListStr.release();
index e568f94..0f302c6 100644 (file)
@@ -127,39 +127,28 @@ _LocaleData::GetIcuString(const String& ospStr, IcuUnicodeString& icuStr)
 ArrayList*
 _LocaleData::ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count)
 {
+       SysTryReturn(NID_LCL, pIcuStrList && count > 0, null, E_INVALID_ARG, "It is invalid argument.");
+       
        result r = E_SUCCESS;
-       ArrayList* pTempArrayList = null;
-       if (pIcuStrList && count > 0)                                               // validating inputs
+       std::unique_ptr< ArrayList> pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+       SysTryReturn(NID_LCL, pTempArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       pTempArrayList->Construct(count);
+       
+       for (int i = 0; i < count; i++)
        {
-               pTempArrayList = new (std::nothrow) ArrayList();
-               if (pTempArrayList)                                                     // If allocation is successful
+               std::unique_ptr< String > pString(new (std::nothrow) String(_LocaleData::GetOspString(pIcuStrList[i])));
+               SysTryReturn(NID_LCL, pString, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               if (!pString->IsEmpty())
                {
-                       r = pTempArrayList->Construct(count);
-                       if (!IsFailed(r))                                                    // If ArrayList::Construct() is successful
-                       {
-                               for (int i = 0; i < count; i++)
-                               {
-                                       String* pString = new (std::nothrow) String();
-                                       if (pString != null)
-                                       {
-                                               *pString = _LocaleData::GetOspString(pIcuStrList[i]);              // Get OSP string from ICU string
-
-                                               if (!pString->IsEmpty())
-                                               {
-                                                       pTempArrayList->Add(*pString);                    // Add OSP string to arraylist if it is not empty
-                                               }
-                                               else
-                                               {
-                                                       delete pString;
-                                               }
-                                       }
-                               }
-                       }
+                       r = pTempArrayList->Add(pString.get());                    // Add OSP string to arraylist if it is not empty
+                       SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to add string [%ls]", pString->GetPointer());
+                       pString.release();
                }
        }
 
        SetLastResult(r);                                                           // Setting last result value
-       return pTempArrayList;                                                      // Return array list
+       return pTempArrayList.release();                                                      // Return array list
 }
 
 // this function convert OSP string array list to ICU string array list