mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-6991 Fix memory leaks in currpinf, uspoof, and some test in intltest.
X-SVN-Rev: 26658
This commit is contained in:
parent
d8e1bc4885
commit
0ea3b2f2ca
6 changed files with 36 additions and 40 deletions
|
@ -183,6 +183,9 @@ void
|
|||
CurrencyPluralInfo::setPluralRules(const UnicodeString& ruleDescription,
|
||||
UErrorCode& status) {
|
||||
if (U_SUCCESS(status)) {
|
||||
if (fPluralRules) {
|
||||
delete fPluralRules;
|
||||
}
|
||||
fPluralRules = PluralRules::createRules(ruleDescription, status);
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +214,9 @@ CurrencyPluralInfo::initialize(const Locale& loc, UErrorCode& status) {
|
|||
}
|
||||
delete fLocale;
|
||||
fLocale = loc.clone();
|
||||
if (fPluralRules) {
|
||||
delete fPluralRules;
|
||||
}
|
||||
fPluralRules = PluralRules::forLocale(loc, status);
|
||||
setupCurrencyPluralPattern(loc, status);
|
||||
}
|
||||
|
@ -222,6 +228,9 @@ CurrencyPluralInfo::setupCurrencyPluralPattern(const Locale& loc, UErrorCode& st
|
|||
return;
|
||||
}
|
||||
|
||||
if (fPluralCountToCurrencyUnitPattern) {
|
||||
deleteHash(fPluralCountToCurrencyUnitPattern);
|
||||
}
|
||||
fPluralCountToCurrencyUnitPattern = initHash(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
|
|
|
@ -680,7 +680,7 @@ uspoof_getSkeleton(const USpoofChecker *sc,
|
|||
// Unnormalized results should be very rare.
|
||||
if (!unorm_isNormalized(result, resultLen, UNORM_NFKD, status)) {
|
||||
normalizedLen = unorm_normalize(result, resultLen, UNORM_NFKD, 0, NULL, 0, status);
|
||||
UChar *normedResult = static_cast<UChar *>(uprv_malloc((normalizedLen+1)*sizeof(UChar)));
|
||||
normedResult = static_cast<UChar *>(uprv_malloc((normalizedLen+1)*sizeof(UChar)));
|
||||
if (normedResult == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
|
|
|
@ -116,11 +116,12 @@ CollationAPITest::TestProperty(/* char* par */)
|
|||
return;
|
||||
}
|
||||
|
||||
col->getKeywordValuesForLocale("", Locale::getEnglish(),true,success);
|
||||
StringEnumeration* kwEnum = col->getKeywordValuesForLocale("", Locale::getEnglish(),true,success);
|
||||
if (U_FAILURE(success)){
|
||||
errcheckln(success, "Get Keyword Values for Locale failed. - %s", u_errorName(success));
|
||||
return;
|
||||
}
|
||||
delete kwEnum;
|
||||
|
||||
col->getVersion(versionArray);
|
||||
for (i=0; i<4; ++i) {
|
||||
|
|
|
@ -370,50 +370,18 @@ void IntlTestDecimalFormatAPI::testAPI(/*char *par*/)
|
|||
}
|
||||
|
||||
delete test;
|
||||
|
||||
// ======= Test API with CurrencyPluralInfo
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
DecimalFormat *df = new DecimalFormat(status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: Couldn't create a DecimalFormat");
|
||||
}
|
||||
|
||||
CurrencyPluralInfo *cpi = new CurrencyPluralInfo(status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: CurrencyPluralInfo(UErrorCode) could not be created");
|
||||
}
|
||||
|
||||
const CurrencyPluralInfo cpi1 = *cpi;
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: const CurrencyPluralInfo(UErrorCode) could not be created");
|
||||
}
|
||||
|
||||
df->adoptCurrencyPluralInfo(cpi);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: DecimalFormat::adoptCurrencyPluralInfo");
|
||||
}
|
||||
|
||||
df->getCurrencyPluralInfo();
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: DecimalFormat::getCurrencyPluralInfo");
|
||||
}
|
||||
|
||||
df->setCurrencyPluralInfo(cpi1);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: DecimalFormat::getCurrencyPluralInfo");
|
||||
}
|
||||
|
||||
delete df;
|
||||
}
|
||||
|
||||
void IntlTestDecimalFormatAPI::TestCurrencyPluralInfo(){
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
CurrencyPluralInfo *cpi = new CurrencyPluralInfo(status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: CurrencyPluralInfo(UErrorCode) could not be created");
|
||||
}
|
||||
|
||||
CurrencyPluralInfo cpi1 = *cpi;
|
||||
|
||||
if(cpi->getDynamicClassID() != CurrencyPluralInfo::getStaticClassID()){
|
||||
errln((UnicodeString)"ERROR: CurrencyPluralInfo::getDynamicClassID() didn't return the expected value");
|
||||
}
|
||||
|
@ -423,8 +391,7 @@ void IntlTestDecimalFormatAPI::TestCurrencyPluralInfo(){
|
|||
errln((UnicodeString)"ERROR: CurrencyPluralInfo::setCurrencyPluralPattern");
|
||||
}
|
||||
|
||||
Locale locale = Locale::getCanada();
|
||||
cpi->setLocale(locale, status);
|
||||
cpi->setLocale(Locale::getCanada(), status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: CurrencyPluralInfo::setLocale");
|
||||
}
|
||||
|
@ -433,6 +400,19 @@ void IntlTestDecimalFormatAPI::TestCurrencyPluralInfo(){
|
|||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: CurrencyPluralInfo::setPluralRules");
|
||||
}
|
||||
|
||||
DecimalFormat *df = new DecimalFormat(status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: Couldn't create a DecimalFormat");
|
||||
}
|
||||
|
||||
df->adoptCurrencyPluralInfo(cpi);
|
||||
|
||||
df->getCurrencyPluralInfo();
|
||||
|
||||
df->setCurrencyPluralInfo(cpi1);
|
||||
|
||||
delete df;
|
||||
}
|
||||
|
||||
void IntlTestDecimalFormatAPI::testRounding(/*char *par*/)
|
||||
|
|
|
@ -395,6 +395,8 @@ void IntlTestSpoof::testConfData() {
|
|||
}
|
||||
}
|
||||
|
||||
uspoof_close(sc);
|
||||
delete [] fileBuf;
|
||||
}
|
||||
#endif // UCONFIG_NO_REGULAR_EXPRESSIONS
|
||||
|
||||
|
|
|
@ -545,8 +545,12 @@ TimeZoneFormatTest::TestTimeRoundTrip(void) {
|
|||
logln((UnicodeString) "Total: " + total + "ms");
|
||||
logln((UnicodeString) "Iteration: " + data.testCounts);
|
||||
|
||||
delete cal;
|
||||
for (i = 0; i < nThreads; i++) {
|
||||
delete threads[i];
|
||||
}
|
||||
delete [] threads;
|
||||
|
||||
delete cal;
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
Loading…
Add table
Reference in a new issue