ICU-770 More data cleanup
X-SVN-Rev: 5651
This commit is contained in:
parent
48538860fd
commit
8f2c4bfb65
@ -780,6 +780,10 @@ InputPath=.\unicode\uclean.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ucln.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\ucln_cmn.h
|
SOURCE=.\ucln_cmn.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
#include "cstring.h"
|
#include "cstring.h"
|
||||||
#include "filestrm.h"
|
#include "filestrm.h"
|
||||||
#include "locmap.h"
|
#include "locmap.h"
|
||||||
|
#include "ucln_cmn.h"
|
||||||
|
|
||||||
/* include system headers */
|
/* include system headers */
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -860,22 +861,25 @@ uprv_tzname(int n)
|
|||||||
|
|
||||||
/* Get and set the ICU data directory --------------------------------------- */
|
/* Get and set the ICU data directory --------------------------------------- */
|
||||||
|
|
||||||
static UBool
|
static char *gDataDirectory = NULL;
|
||||||
gHaveDataDirectory=FALSE;
|
|
||||||
|
|
||||||
static const char *gDataDirectory = "";
|
UBool putil_cleanup(void)
|
||||||
|
{
|
||||||
|
if (gDataDirectory) {
|
||||||
|
uprv_free(gDataDirectory);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the data directory.
|
* Set the data directory.
|
||||||
* Make a copy of the passed string, and set the global data dir to point to it.
|
* Make a copy of the passed string, and set the global data dir to point to it.
|
||||||
* Deliberately leak any previously set string, on the chance that some code
|
|
||||||
* may have called getDataDirectory() and still be using the old string.
|
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
u_setDataDirectory(const char *directory) {
|
u_setDataDirectory(const char *directory) {
|
||||||
char *newDataDir;
|
char *newDataDir;
|
||||||
|
|
||||||
if(directory!=NULL && *directory != 0) {
|
if(directory!=NULL) {
|
||||||
int length=uprv_strlen(directory);
|
int length=uprv_strlen(directory);
|
||||||
newDataDir = (char *)uprv_malloc(length + 2);
|
newDataDir = (char *)uprv_malloc(length + 2);
|
||||||
uprv_strcpy(newDataDir, directory);
|
uprv_strcpy(newDataDir, directory);
|
||||||
@ -884,16 +888,15 @@ u_setDataDirectory(const char *directory) {
|
|||||||
newDataDir[length] = 0;
|
newDataDir[length] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
umtx_lock(NULL);
|
||||||
|
if (gDataDirectory) {
|
||||||
|
uprv_free(gDataDirectory);
|
||||||
|
}
|
||||||
gDataDirectory = newDataDir;
|
gDataDirectory = newDataDir;
|
||||||
gHaveDataDirectory=TRUE;
|
umtx_unlock(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* #include <stdio.h> */
|
|
||||||
/* #include <unistd.h> */
|
|
||||||
|
|
||||||
#if HAVE_DLOPEN
|
#if HAVE_DLOPEN
|
||||||
#define LIB_PREFIX "lib"
|
#define LIB_PREFIX "lib"
|
||||||
#else
|
#else
|
||||||
@ -906,7 +909,7 @@ u_getDataDirectory(void) {
|
|||||||
char pathBuffer[1024];
|
char pathBuffer[1024];
|
||||||
|
|
||||||
/* if we have the directory, then return it immediately */
|
/* if we have the directory, then return it immediately */
|
||||||
if(gHaveDataDirectory) {
|
if(gDataDirectory) {
|
||||||
return gDataDirectory;
|
return gDataDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,6 +1000,11 @@ u_getDataDirectory(void) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
if(path==NULL) {
|
||||||
|
/* It looks really bad, set it to something. */
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
|
||||||
u_setDataDirectory(path);
|
u_setDataDirectory(path);
|
||||||
return gDataDirectory;
|
return gDataDirectory;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "cmemory.h"
|
#include "cmemory.h"
|
||||||
#include "cstring.h"
|
#include "cstring.h"
|
||||||
#include "ustr_imp.h"
|
#include "ustr_imp.h"
|
||||||
|
#include "ucln_cmn.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since genprops overrides the general category for some control codes,
|
* Since genprops overrides the general category for some control codes,
|
||||||
@ -266,6 +267,19 @@ isAcceptable(void *context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UBool
|
||||||
|
uchar_cleanup()
|
||||||
|
{
|
||||||
|
if (propsData) {
|
||||||
|
udata_close(propsData);
|
||||||
|
propsData = NULL;
|
||||||
|
}
|
||||||
|
propsTable = NULL;
|
||||||
|
ucharsTable = NULL;
|
||||||
|
havePropsData = FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int8_t
|
static int8_t
|
||||||
loadPropsData() {
|
loadPropsData() {
|
||||||
/* load Unicode character properties data from file if necessary */
|
/* load Unicode character properties data from file if necessary */
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
typedef enum ECleanupLibraryType {
|
typedef enum ECleanupLibraryType {
|
||||||
UCLN_START = -1,
|
UCLN_START = -1,
|
||||||
|
UCLN_CUSTOM, /* Custom is for anyone else. */
|
||||||
UCLN_LAYOUT,
|
UCLN_LAYOUT,
|
||||||
UCLN_USTDIO,
|
UCLN_USTDIO,
|
||||||
UCLN_I18N,
|
UCLN_I18N,
|
||||||
|
@ -46,11 +46,15 @@ void u_cleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*unorm_cleanup();*/
|
||||||
|
unames_cleanup();
|
||||||
|
uchar_cleanup();
|
||||||
uloc_cleanup();
|
uloc_cleanup();
|
||||||
ustring_cleanup();
|
ustring_cleanup();
|
||||||
ucnv_cleanup();
|
ucnv_cleanup();
|
||||||
ucnv_io_cleanup();
|
ucnv_io_cleanup();
|
||||||
ures_cleanup();
|
ures_cleanup();
|
||||||
udata_cleanup();
|
udata_cleanup();
|
||||||
|
putil_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,12 @@
|
|||||||
|
|
||||||
/* These are the cleanup functions for various APIs. */
|
/* These are the cleanup functions for various APIs. */
|
||||||
|
|
||||||
|
U_CFUNC UBool unames_cleanup(void);
|
||||||
|
|
||||||
U_CFUNC UBool unorm_cleanup(void);
|
U_CFUNC UBool unorm_cleanup(void);
|
||||||
|
|
||||||
|
U_CFUNC UBool uchar_cleanup(void);
|
||||||
|
|
||||||
U_CFUNC UBool uloc_cleanup(void);
|
U_CFUNC UBool uloc_cleanup(void);
|
||||||
|
|
||||||
U_CFUNC UBool ustring_cleanup(void);
|
U_CFUNC UBool ustring_cleanup(void);
|
||||||
@ -35,4 +39,6 @@ U_CFUNC UBool ures_cleanup(void);
|
|||||||
|
|
||||||
U_CFUNC UBool udata_cleanup(void);
|
U_CFUNC UBool udata_cleanup(void);
|
||||||
|
|
||||||
|
U_CFUNC UBool putil_cleanup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1231,20 +1231,26 @@ UBool uloc_cleanup(void) {
|
|||||||
int32_t localeCount;
|
int32_t localeCount;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|
||||||
umtx_lock(NULL);
|
if (_installedLocales) {
|
||||||
|
temp = _installedLocales;
|
||||||
|
_installedLocales = NULL;
|
||||||
|
|
||||||
temp = _installedLocales;
|
localeCount = _installedLocalesCount;
|
||||||
_installedLocales = NULL;
|
_installedLocalesCount = 0;
|
||||||
|
|
||||||
localeCount = _installedLocalesCount;
|
for (i = 0; i < localeCount; i++) {
|
||||||
_installedLocalesCount = 0;
|
uprv_free(temp[i]);
|
||||||
|
}
|
||||||
umtx_unlock(NULL);
|
uprv_free(temp);
|
||||||
|
}
|
||||||
for (i = 0; i < localeCount; i++) {
|
if (_isoCountries) {
|
||||||
uprv_free(temp[i]);
|
uprv_free(_isoCountries);
|
||||||
|
_isoCountries = NULL;
|
||||||
|
}
|
||||||
|
if (_isoLanguages) {
|
||||||
|
uprv_free(_isoLanguages);
|
||||||
|
_isoLanguages = NULL;
|
||||||
}
|
}
|
||||||
uprv_free(temp);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +286,19 @@ u_enumCharNames(UChar32 start, UChar32 limit,
|
|||||||
|
|
||||||
/* implementation ----------------------------------------------------------- */
|
/* implementation ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
UBool
|
||||||
|
unames_cleanup()
|
||||||
|
{
|
||||||
|
if(uCharNamesData) {
|
||||||
|
udata_close(uCharNamesData);
|
||||||
|
uCharNamesData = NULL;
|
||||||
|
}
|
||||||
|
if(uCharNames) {
|
||||||
|
uCharNames = NULL;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static UBool
|
static UBool
|
||||||
isDataLoaded(UErrorCode *pErrorCode) {
|
isDataLoaded(UErrorCode *pErrorCode) {
|
||||||
/* load UCharNames from file if necessary */
|
/* load UCharNames from file if necessary */
|
||||||
|
@ -17,12 +17,15 @@
|
|||||||
#include "ucln.h"
|
#include "ucln.h"
|
||||||
#include "ucln_in.h"
|
#include "ucln_in.h"
|
||||||
|
|
||||||
UBool i18n_cleanup(void)
|
static UBool i18n_cleanup(void)
|
||||||
{
|
{
|
||||||
|
ucol_bld_cleanup();
|
||||||
ucol_cleanup();
|
ucol_cleanup();
|
||||||
|
timeZone_cleanup();
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i18n_registerCleanup()
|
void ucln_i18n_registerCleanup()
|
||||||
{
|
{
|
||||||
ucln_registerCleanup(UCLN_I18N, i18n_cleanup);
|
ucln_registerCleanup(UCLN_I18N, i18n_cleanup);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "unicode/utypes.h"
|
#include "unicode/utypes.h"
|
||||||
|
|
||||||
/* Main library cleanup function. */
|
/* Main library cleanup function. */
|
||||||
U_CFUNC void i18n_registerCleanup(void);
|
U_CFUNC void ucln_i18n_registerCleanup(void);
|
||||||
|
|
||||||
U_CFUNC UBool ucol_cleanup(void);
|
U_CFUNC UBool ucol_cleanup(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user