ICU-2787 We must allow u_cleanup to be called twice, and to allow the library to be reinitialized.

X-SVN-Rev: 11877
This commit is contained in:
George Rhoten 2003-05-09 23:20:55 +00:00
parent 8cd78a419a
commit 7ace7f019a

View File

@ -39,10 +39,6 @@
#include "uhash.h" #include "uhash.h"
#include "ucln_cmn.h" #include "ucln_cmn.h"
U_NAMESPACE_BEGIN
const char Locale::fgClassID=0;
static Locale* availableLocaleList = NULL; static Locale* availableLocaleList = NULL;
static int32_t availableLocaleListCount; static int32_t availableLocaleListCount;
typedef enum ELocalePos { typedef enum ELocalePos {
@ -78,8 +74,6 @@ typedef enum ELocalePos {
static Locale *gLocaleCache = NULL; static Locale *gLocaleCache = NULL;
static Locale *gDefaultLocale = NULL; static Locale *gDefaultLocale = NULL;
U_NAMESPACE_END
UBool UBool
locale_cleanup(void) locale_cleanup(void)
{ {
@ -91,12 +85,20 @@ locale_cleanup(void)
} }
availableLocaleListCount = 0; availableLocaleListCount = 0;
delete [] gLocaleCache; if (gLocaleCache) {
delete gDefaultLocale; delete [] gLocaleCache;
gLocaleCache = NULL;
}
if (gDefaultLocale) {
delete gDefaultLocale;
gDefaultLocale = NULL;
}
return TRUE; return TRUE;
} }
U_NAMESPACE_BEGIN U_NAMESPACE_BEGIN
const char Locale::fgClassID=0;
void locale_set_default_internal(const char *id) void locale_set_default_internal(const char *id)
{ {
U_NAMESPACE_USE U_NAMESPACE_USE
@ -928,7 +930,9 @@ Locale::getLocaleCache(void)
tLocaleCache = NULL; tLocaleCache = NULL;
} }
umtx_unlock(NULL); umtx_unlock(NULL);
delete [] tLocaleCache; // Fancy array delete will destruct each member. if (tLocaleCache) {
delete [] tLocaleCache; // Fancy array delete will destruct each member.
}
} }
return gLocaleCache; return gLocaleCache;
} }