From 689ac9f998695c8bfa4bec83b0fb08f80b22f2a3 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Mon, 17 Apr 2006 07:37:21 +0000 Subject: [PATCH] ICU-5161 Fix a memory leak. X-SVN-Rev: 19558 --- icu4c/source/i18n/dtfmtsym.cpp | 16 +++++++++------- icu4c/source/test/intltest/calregts.cpp | 6 +++--- icu4c/source/test/intltest/tzbdtest.cpp | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 27503c7b8da..406f727b0d1 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -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; rowsetValueDeleter(deleteUnicodeStringArray); int32_t pos = -1; const UHashElement* elem = NULL; // walk through the hash table and create a deep clone diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index b515cf8f48e..23ca559522e 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -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; icount(status); ++i) { TimeZone *zone = TimeZone::createTimeZone(*ids->snext(status)); GregorianCalendar *cal = new GregorianCalendar(zone, status); diff --git a/icu4c/source/test/intltest/tzbdtest.cpp b/icu4c/source/test/intltest/tzbdtest.cpp index 6e305f458f9..88e0fab9c7c 100644 --- a/icu4c/source/test/intltest/tzbdtest.cpp +++ b/icu4c/source/test/intltest/tzbdtest.cpp @@ -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;