ICU-5161 Fix a memory leak.

X-SVN-Rev: 19558
This commit is contained in:
George Rhoten 2006-04-17 07:37:21 +00:00
parent 69dc11a58d
commit 689ac9f998
3 changed files with 14 additions and 11 deletions

View File

@ -1490,43 +1490,43 @@ DateFormatSymbols::initZoneStrings(UErrorCode &status){
//fetch the strings with fine grained fallback
const UChar* str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_SHORT_STANDARD, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_SHORT_STANDARD].setTo(str, len);
array[TIMEZONE_SHORT_STANDARD].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_SHORT_GENERIC, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_SHORT_GENERIC].setTo(str, len);
array[TIMEZONE_SHORT_GENERIC].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_SHORT_DAYLIGHT, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_SHORT_DAYLIGHT].setTo(str, len);
array[TIMEZONE_SHORT_DAYLIGHT].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_LONG_STANDARD, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_LONG_STANDARD].setTo(str, len);
array[TIMEZONE_LONG_STANDARD].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_LONG_GENERIC, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_LONG_GENERIC].setTo(str, len);
array[TIMEZONE_LONG_GENERIC].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_LONG_DAYLIGHT, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_LONG_DAYLIGHT].setTo(str, len);
array[TIMEZONE_LONG_DAYLIGHT].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
str = ures_getStringByKeyWithFallback(&zoneItem,UTZ_EXEMPLAR_CITY, &len, &tempStatus);
if(U_SUCCESS(tempStatus)){
array[TIMEZONE_EXEMPLAR_CITY].setTo(str, len);
array[TIMEZONE_EXEMPLAR_CITY].setTo(TRUE, str, len);
}else{
tempStatus = U_ZERO_ERROR;
}
@ -1603,6 +1603,7 @@ DateFormatSymbols::initZoneStrings(const UnicodeString** strings, int32_t rowCou
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
fZoneStringsHash->setValueDeleter(deleteUnicodeStringArray);
for (int32_t row=0; row<rowCount; ++row){
// the first string in the array is the key.
UnicodeString key = strings[row][0];
@ -1725,6 +1726,7 @@ DateFormatSymbols::createZoneStringsHash(const Hashtable* otherHash){
if(U_FAILURE(status)){
return NULL;
}
hash->setValueDeleter(deleteUnicodeStringArray);
int32_t pos = -1;
const UHashElement* elem = NULL;
// walk through the hash table and create a deep clone

View File

@ -1,7 +1,7 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2005, International Business Machines Corporation and
* others. All Rights Reserved.
* Copyright (c) 1997-2006, International Business Machines Corporation
* and others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
@ -224,7 +224,7 @@ CalendarRegressionTest::test4031502()
cl->get(UCAL_HOUR, status);
failure(status, "cl->get(UCAL_HOUR, status)");
status = U_ZERO_ERROR;
delete tz;
delete cl;
for (int32_t i=0; i<ids->count(status); ++i) {
TimeZone *zone = TimeZone::createTimeZone(*ids->snext(status));
GregorianCalendar *cal = new GregorianCalendar(zone, status);

View File

@ -1,6 +1,6 @@
/***********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2005, International Business Machines Corporation
* Copyright (c) 1997-2006, International Business Machines Corporation
* and others. All Rights Reserved.
***********************************************************************/
@ -312,6 +312,7 @@ TimeZoneBoundaryTest::TestBoundaries()
verifyDST(tempcal->getTime(status),pst, TRUE, inDST, -8*ONE_HOUR,inDST ? -7*ONE_HOUR : -8*ONE_HOUR);
}
TimeZone::setDefault(*save);
delete save;
delete utccal;
delete tempcal;