ICU-5955 Add deleter for TimeZoneRule.

X-SVN-Rev: 24116
This commit is contained in:
Michael Ow 2008-06-06 18:44:54 +00:00
parent ef6684309b
commit 8d8b77b563

View file

@ -20,6 +20,14 @@
U_NAMESPACE_BEGIN
// This is the deleter that will be use to remove TimeZoneRule
U_CDECL_BEGIN
static void U_CALLCONV
deleteTimeZoneRule(void* obj) {
delete (TimeZoneRule*) obj;
}
U_CDECL_END
// Smybol characters used by RFC2445 VTIMEZONE
static const UChar COLON = 0x3A; /* : */
static const UChar SEMICOLON = 0x3B; /* ; */
@ -1335,6 +1343,9 @@ VTimeZone::parse(UErrorCode& status) {
if (U_FAILURE(status)) {
goto cleanupParse;
}
// Set the deleter to remove TimeZoneRule vectors to avoid memory leaks due to unowned TimeZoneRules.
rules->setDeleter(deleteTimeZoneRule);
dates = new UVector(uhash_deleteUnicodeString, uhash_compareUnicodeString, status);
if (U_FAILURE(status)) {
goto cleanupParse;