From 3dffeab2e6ac43b04cdd66a080f57a3929f303c2 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Tue, 15 Aug 2006 06:47:19 +0000 Subject: [PATCH] ICU-5320 Don't use global new and delete, and add a patch for MinGW X-SVN-Rev: 20064 --- icu4c/source/i18n/winnmfmt.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/icu4c/source/i18n/winnmfmt.cpp b/icu4c/source/i18n/winnmfmt.cpp index 20bc612d205..175b89e171e 100644 --- a/icu4c/source/i18n/winnmfmt.cpp +++ b/icu4c/source/i18n/winnmfmt.cpp @@ -137,7 +137,7 @@ Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro if (!U_FAILURE(status)) { fLCID = locale.getLCID(); - fFormatInfo = new FormatInfo(); + fFormatInfo = (FormatInfo*)uprv_malloc(sizeof(FormatInfo)); if (fCurrency) { getCurrencyFormat(&fFormatInfo->currency, fLCID); @@ -161,7 +161,7 @@ Win32NumberFormat::~Win32NumberFormat() freeNumberFormat(&fFormatInfo->number); } - delete fFormatInfo; + uprv_free(fFormatInfo); } Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other) @@ -172,8 +172,13 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other) this->fLCID = other.fLCID; this->fFractionDigitsSet = other.fFractionDigitsSet; - this->fFormatInfo = new FormatInfo; - *this->fFormatInfo = *other.fFormatInfo; + if (fCurrency) { + freeCurrencyFormat(&fFormatInfo->currency); + getCurrencyFormat(&fFormatInfo->currency, fLCID); + } else { + freeNumberFormat(&fFormatInfo->number); + getNumberFormat(&fFormatInfo->number, fLCID); + } return *this; } @@ -230,7 +235,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen nBuffer[0] = 0x0000; va_start(args, fmt); - result = vswprintf(nBuffer, STACK_BUFFER_SIZE, fmt, args); + result = _vsnwprintf(nBuffer, STACK_BUFFER_SIZE, fmt, args); va_end(args); if (result < 0) { @@ -243,7 +248,7 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen nBuffer = NEW_ARRAY(UChar, newLength + 1); va_start(args, fmt); - result = vswprintf(nBuffer, newLength + 1, fmt, args); + result = _vsnwprintf(nBuffer, newLength + 1, fmt, args); va_end(args); }