]> granicus.if.org Git - icu/commitdiff
ICU-10640 Change MeasureFormat::adoptNumberFormat to adhere to ICU users' guide.
authorTravis Keep <keep94@gmail.com>
Mon, 10 Feb 2014 22:55:18 +0000 (22:55 +0000)
committerTravis Keep <keep94@gmail.com>
Mon, 10 Feb 2014 22:55:18 +0000 (22:55 +0000)
X-SVN-Rev: 35117

icu4c/source/i18n/measfmt.cpp

index c9a10685c73299c5af85b200459d4bb9f4c4f5d7..fffdffdc60e18733107ec5dffbb8d6b95e110347 100644 (file)
@@ -623,16 +623,16 @@ void MeasureFormat::initMeasureFormat(
 
 void MeasureFormat::adoptNumberFormat(
         NumberFormat *nfToAdopt, UErrorCode &status) {
+    LocalPointer<NumberFormat> nf(nfToAdopt);
     if (U_FAILURE(status)) {
-        delete nfToAdopt;
         return;
     }
-    SharedNumberFormat *shared = new SharedNumberFormat(nfToAdopt);
+    SharedNumberFormat *shared = new SharedNumberFormat(nf.getAlias());
     if (shared == NULL) {
         status = U_MEMORY_ALLOCATION_ERROR;
-        delete nfToAdopt;
         return;
     }
+    nf.orphan();
     SharedObject::copyPtr(shared, numberFormat);
 }