X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/test/intltest/winutil.cpp diff --git a/icuSources/test/intltest/winutil.cpp b/icuSources/test/intltest/winutil.cpp index 1963221e..0b7bd6d7 100644 --- a/icuSources/test/intltest/winutil.cpp +++ b/icuSources/test/intltest/winutil.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************** -* Copyright (C) 2005-2006, International Business Machines +* Copyright (C) 2005-2011, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -11,12 +11,13 @@ #include "unicode/utypes.h" -#ifdef U_WINDOWS +#if U_PLATFORM_HAS_WIN32_API #if !UCONFIG_NO_FORMATTING #include "winutil.h" #include "locmap.h" +#include "unicode/uloc.h" # define WIN32_LEAN_AND_MEAN # define VC_EXTRALEAN @@ -26,6 +27,7 @@ # define NOMCX # include # include +# include static Win32Utilities::LCIDRecord *lcidRecords = NULL; static int32_t lcidCount = 0; @@ -33,6 +35,7 @@ static int32_t lcidMax = 0; BOOL CALLBACK EnumLocalesProc(LPSTR lpLocaleString) { + const char* localeID = NULL; UErrorCode status = U_ZERO_ERROR; if (lcidCount >= lcidMax) { @@ -49,7 +52,11 @@ BOOL CALLBACK EnumLocalesProc(LPSTR lpLocaleString) sscanf(lpLocaleString, "%8x", &lcidRecords[lcidCount].lcid); - lcidRecords[lcidCount].localeID = uprv_convertToPosix(lcidRecords[lcidCount].lcid, &status); + localeID = uprv_convertToPosix(lcidRecords[lcidCount].lcid, &status); + + lcidRecords[lcidCount].localeID = new char[strlen(localeID)]; + + strcpy(lcidRecords[lcidCount].localeID, localeID); lcidCount += 1; @@ -73,9 +80,12 @@ Win32Utilities::LCIDRecord *Win32Utilities::getLocales(int32_t &localeCount) void Win32Utilities::freeLocales(LCIDRecord *records) { + for (int i = 0; i < lcidCount; i++) { + delete lcidRecords[i].localeID; + } delete[] records; } #endif /* #if !UCONFIG_NO_FORMATTING */ -#endif /* #ifdef U_WINDOWS */ +#endif /* U_PLATFORM_HAS_WIN32_API */