From 3d6cf303783bf6cc4382de86d55b838dbe601732 Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Thu, 11 Oct 2012 01:07:10 +0000 Subject: [PATCH] ICU-9606 Review comments: Use LocalPointer for btzClone, delete incorrect comment X-SVN-Rev: 32594 --- icu4c/source/i18n/ucal.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/icu4c/source/i18n/ucal.cpp b/icu4c/source/i18n/ucal.cpp index 30c8797e18..0015baef24 100644 --- a/icu4c/source/i18n/ucal.cpp +++ b/icu4c/source/i18n/ucal.cpp @@ -19,6 +19,7 @@ #include "unicode/simpletz.h" #include "unicode/ustring.h" #include "unicode/strenum.h" +#include "unicode/localpointer.h" #include "cmemory.h" #include "cstring.h" #include "ustrenum.h" @@ -736,13 +737,10 @@ ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType typ } UDate base = ((Calendar*)cal)->getTime(*status); const TimeZone& tz = ((Calendar*)cal)->getTimeZone(); - // The reference returned from Calendar::getTimeZone() "is only valid until clients - // make another call to adoptTimeZone or setTimeZone, or this Calendar is destroyed." - // Add a mutex lock until after we clone (or fail)? const BasicTimeZone * btz = dynamic_cast(&tz); if (btz != NULL && U_SUCCESS(*status)) { TimeZoneTransition tzt; - BasicTimeZone * btzClone = static_cast(btz->clone()); // getNext/PreviousTransition are non-const + LocalPointer btzClone(static_cast(btz->clone())); // getNext/PreviousTransition are non-const UBool inclusive = (type == UCAL_TZ_TRANSITION_NEXT_INCLUSIVE || type == UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE); UBool result = (type == UCAL_TZ_TRANSITION_NEXT || type == UCAL_TZ_TRANSITION_NEXT_INCLUSIVE)? btzClone->getNextTransition(base, inclusive, tzt):