if (!currCode.IsEmpty() && !currSymbol.IsEmpty())
{
- Currency* pCurr = new (std::nothrow) Currency;
+ std::unique_ptr< Currency > pCurr(new (std::nothrow) Currency);
SysTryReturn(NID_LCL, pCurr, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
pCurr->__currencyCodeSymbol = currCode + "_" + currSymbol;
- if (!pNewList->Contains(*pCurr))
+ if (!pNewList->Contains(*(pCurr.get())))
{
- result r = pNewList->Add(*(pCurr));
- if (IsFailed(r))
- {
- delete pCurr;
- SetLastResult(E_SYSTEM);
- return null;
- }
+ result r = pNewList->Add(*(pCurr.get()));
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "Itis fail to make the currency list.");
+ pCurr.release();
}
}
}
Locale ospLocale = _LocaleImpl(*(pIcuLocaleList + i)).GetOspLocale();
if (_LocaleImpl::IsSupported(ospLocale))
{
- Locale* pLocale = new (std::nothrow) Locale(ospLocale);
+ std::unique_ptr< Locale > pLocale(new (std::nothrow) Locale(ospLocale));
SysTryReturn(NID_LCL, pLocale, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
- if (!pAvailableLocaleList->Contains(*pLocale))
+ if (!pAvailableLocaleList->Contains(*(pLocale.get())))
{
- r = pAvailableLocaleList->Add(*pLocale);
- if (IsFailed(r))
- {
- delete pLocale;
- SetLastResult(E_SYSTEM);
- return null;
- }
+ r = pAvailableLocaleList->Add(*(pLocale.get()));
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make the locale list");
+ pLocale.release();
}
}
}
SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pLanguageMap->Add(*(pLanguageCode.get()), *(pDummyValue.get()));
-
- if (IsFailed(r))
- {
- SetLastResult(E_SYSTEM);
- return null;
- }
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make a language list.");
pLanguageCode.release();
pDummyValue.release();
}
while (pIcuTZStr != null)
{
- String* pTimeZone = new (std::nothrow) String(pIcuTZStr);
+ std::unique_ptr< String > pTimeZone(new (std::nothrow) String(pIcuTZStr));
SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- if (!pTimeZoneMap->ContainsKey(*pTimeZone) && pTZMap->ContainsKey(*pTimeZone))
+ if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())) && pTZMap->ContainsKey(*(pTimeZone.get())))
{
- String* pDummyValue = new (std::nothrow) String();
- r = pTimeZoneMap->Add(*pTimeZone, *pDummyValue);
+ std::unique_ptr< String > pDummyValue(new (std::nothrow) String());
+ SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
if (IsFailed(r))
{
- delete pTimeZone;
- delete pDummyValue;
pTZMap->RemoveAll();
+ delete pTZMap;
SetLastResult(E_SYSTEM);
return null;
}
+ pTimeZone.release();
+ pDummyValue.release();
}
pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
}
SetLastResult(E_SUCCESS);
pTZMap->RemoveAll();
+ delete pTZMap;
return pTimeZoneMap.release();
}
do
{
- String* pTimeZone = new (std::nothrow) String(TimeZoneList[index++]);
+ std::unique_ptr< String > pTimeZone(new (std::nothrow) String(TimeZoneList[index++]));
SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- if (!pTimeZoneMap->ContainsKey(*pTimeZone))
+ if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())))
{
- String* pDummyValue = new (std::nothrow) String();
+ std::unique_ptr< String > pDummyValue (new (std::nothrow) String());
+ SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- r = pTimeZoneMap->Add(*pTimeZone, *pDummyValue);
- if (IsFailed(r))
- {
- delete pTimeZone;
- delete pDummyValue;
- SetLastResult(E_SYSTEM);
- return null;
- }
+ r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
+ SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make Timezone list.");
+
+ pTimeZone.release();
+ pDummyValue.release();
}
}while (index < TIMEZONE_MAX);