mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-05 13:35:32 +00:00
ICU-770 More data cleanup
X-SVN-Rev: 5678
This commit is contained in:
parent
28772efa7b
commit
420c9b317c
7 changed files with 43 additions and 21 deletions
|
@ -32,12 +32,10 @@
|
|||
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/resbund.h"
|
||||
#include "uresimp.h"
|
||||
#include "mutex.h"
|
||||
#include "unicode/unicode.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "ucln_cmn.h"
|
||||
|
||||
/*Character separating the posix id fields*/
|
||||
// '_'
|
||||
|
@ -473,7 +471,7 @@ Locale::createFromName (const char *name)
|
|||
/* for some reason */
|
||||
if(namelen > buflen) {
|
||||
buflen = namelen+1;
|
||||
heap = (char*)uprv_malloc(buflen);
|
||||
heap = new char[buflen];
|
||||
buf = heap;
|
||||
}
|
||||
|
||||
|
@ -482,7 +480,7 @@ Locale::createFromName (const char *name)
|
|||
Locale l(buf);
|
||||
if(heap != NULL)
|
||||
{
|
||||
free(heap);
|
||||
delete heap;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
@ -686,29 +684,29 @@ Locale::getDisplayName( const Locale& inLocale,
|
|||
return result;
|
||||
}
|
||||
|
||||
UBool
|
||||
locale_cleanup(void)
|
||||
{
|
||||
if (availableLocaleList) {
|
||||
delete []availableLocaleList;
|
||||
availableLocaleList = NULL;
|
||||
}
|
||||
availableLocaleListCount = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const Locale*
|
||||
Locale::getAvailableLocales(int32_t& count)
|
||||
{
|
||||
// for now, there is a hardcoded list, so just walk through that list and set it up.
|
||||
if (availableLocaleList == 0) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ResourceBundle index(UnicodeString(""), Locale(kIndexLocaleName), status);
|
||||
ResourceBundle locales = index.get(kIndexTag, status);
|
||||
int32_t locCount = uloc_countAvailable();
|
||||
Locale *newLocaleList = new Locale[locCount];
|
||||
|
||||
char name[96];
|
||||
locales.resetIterator();
|
||||
count = locCount;
|
||||
|
||||
count = locales.getSize();
|
||||
|
||||
Locale *newLocaleList = new Locale[count];
|
||||
|
||||
int32_t i = 0;
|
||||
UnicodeString temp;
|
||||
while(locales.hasNext()) {
|
||||
temp = locales.getNextString(status);
|
||||
temp.extract(0, temp.length(), name);
|
||||
name[temp.length()] = '\0';
|
||||
newLocaleList[i++].setFromPOSIXID(name);
|
||||
while(--locCount >= 0) {
|
||||
newLocaleList[locCount].setFromPOSIXID(uloc_getAvailable(locCount));
|
||||
}
|
||||
|
||||
Mutex mutex;
|
||||
|
|
|
@ -867,6 +867,7 @@ UBool putil_cleanup(void)
|
|||
{
|
||||
if (gDataDirectory) {
|
||||
uprv_free(gDataDirectory);
|
||||
gDataDirectory = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ void u_cleanup(void)
|
|||
/*unorm_cleanup();*/
|
||||
unames_cleanup();
|
||||
uchar_cleanup();
|
||||
locale_cleanup();
|
||||
uloc_cleanup();
|
||||
ustring_cleanup();
|
||||
ucnv_cleanup();
|
||||
|
|
|
@ -27,6 +27,8 @@ U_CFUNC UBool unorm_cleanup(void);
|
|||
|
||||
U_CFUNC UBool uchar_cleanup(void);
|
||||
|
||||
U_CFUNC UBool locale_cleanup(void);
|
||||
|
||||
U_CFUNC UBool uloc_cleanup(void);
|
||||
|
||||
U_CFUNC UBool ustring_cleanup(void);
|
||||
|
|
|
@ -204,4 +204,12 @@ CalendarTimeZoneTest::dateToFields(UDate date, int32_t& y, int32_t& m, int32_t&
|
|||
releaseCalendar(cal);
|
||||
}
|
||||
|
||||
void CalendarTimeZoneTest::cleanup()
|
||||
{
|
||||
delete fgDateFormat;
|
||||
fgDateFormat = 0;
|
||||
delete fgCalendar;
|
||||
fgCalendar = 0;
|
||||
}
|
||||
|
||||
//eof
|
||||
|
|
|
@ -19,6 +19,8 @@ class Calendar;
|
|||
**/
|
||||
class CalendarTimeZoneTest : public IntlTest
|
||||
{
|
||||
public:
|
||||
static void cleanup();
|
||||
protected:
|
||||
// Return true if the given status indicates failure. Also has the side effect
|
||||
// of calling errln(). Msg should be of the form "Class::Method" in general.
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
#include "unicode/ures.h"
|
||||
#include "unicode/smpdtfmt.h"
|
||||
#include "unicode/ucnv.h"
|
||||
#include "unicode/uclean.h"
|
||||
|
||||
#include "intltest.h"
|
||||
#include "caltztst.h"
|
||||
#include "itmajor.h"
|
||||
|
||||
#ifdef XP_MAC_CONSOLE
|
||||
|
@ -1060,6 +1062,14 @@ main(int argc, char* argv[])
|
|||
if (execCount <= 0) {
|
||||
fprintf(stdout, "***** Not all called tests actually exist! *****\n");
|
||||
}
|
||||
/* Call it twice to make sure that the defaults were reset */
|
||||
u_cleanup();
|
||||
u_cleanup();
|
||||
|
||||
/* delete these just to see how delete reacts to u_cleanup().
|
||||
This is done in the wrong order on purpose.
|
||||
Normally this should happen first */
|
||||
CalendarTimeZoneTest::cleanup();
|
||||
|
||||
return major.getErrors();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue