]> granicus.if.org Git - icu/commitdiff
ICU-9606 Review comments: Use LocalPointer for btzClone, delete incorrect comment
authorPeter Edberg <pedberg@unicode.org>
Thu, 11 Oct 2012 01:07:10 +0000 (01:07 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 11 Oct 2012 01:07:10 +0000 (01:07 +0000)
X-SVN-Rev: 32594

icu4c/source/i18n/ucal.cpp

index 30c8797e18c5377bd33a8de3c72e52edf9b01924..0015baef24ac52b416d4e6d1eda7377c7c6c7c6b 100644 (file)
@@ -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<const BasicTimeZone *>(&tz);
     if (btz != NULL && U_SUCCESS(*status)) {
         TimeZoneTransition tzt;
-        BasicTimeZone * btzClone = static_cast<BasicTimeZone *>(btz->clone()); // getNext/PreviousTransition are non-const
+        LocalPointer<BasicTimeZone> btzClone(static_cast<BasicTimeZone *>(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):