diff --git a/icu4c/source/common/Makefile.in b/icu4c/source/common/Makefile.in index c8031cfd127..82e85e55d09 100644 --- a/icu4c/source/common/Makefile.in +++ b/icu4c/source/common/Makefile.in @@ -77,7 +77,7 @@ uchar.o ucmp8.o ucmp16.o ucmp32.o ucmpe32.o uvector.o uhash.o uhash_us.o \ unames.o unicode.o unistr.o ustring.o cstring.o utf_impl.o \ scsu.o ucnv.o ucnv_bld.o ucnv_cb.o ucnv_cnv.o ucnv_err.o ucnv_io.o convert.o \ ucnvlat1.o ucnvmbcs.o ucnv_utf.o ucnv2022.o ucnvhz.o ucnv_lmb.o ucnvscsu.o \ -ustream.o uscript.o ucnvisci.o +ustream.o uscript.o ucnvisci.o ucln_cmn.o STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O)) diff --git a/icu4c/source/common/ucln_cmn.c b/icu4c/source/common/ucln_cmn.c index b83d0d8022d..7988daefcee 100644 --- a/icu4c/source/common/ucln_cmn.c +++ b/icu4c/source/common/ucln_cmn.c @@ -24,4 +24,6 @@ void u_cleanup(void) ucln_ustring(); ucln_ucnv(); ucln_ures(); -} \ No newline at end of file + udata_cleanup(); +} + diff --git a/icu4c/source/common/ucln_cmn.h b/icu4c/source/common/ucln_cmn.h index e7fd61a734b..09977bc9cf4 100644 --- a/icu4c/source/common/ucln_cmn.h +++ b/icu4c/source/common/ucln_cmn.h @@ -27,4 +27,6 @@ U_CAPI UBool U_EXPORT2 ucln_uloc(void); U_CAPI UBool U_EXPORT2 ucln_ustring(void); +U_CAPI UBool U_EXPORT2 udata_cleanup(void); + #endif diff --git a/icu4c/source/common/udata.c b/icu4c/source/common/udata.c index 7cc1a6c644a..c4e5339de01 100644 --- a/icu4c/source/common/udata.c +++ b/icu4c/source/common/udata.c @@ -22,6 +22,7 @@ #include "unicode/udata.h" #include "unicode/uversion.h" #include "uhash.h" +#include "ucln_cmn.h" #ifdef OS390 #include @@ -545,7 +546,7 @@ pointerTOCLookupFn(const UDataMemory *pData, /* common library functions ------------------------------------------------- */ -static UDataMemory commonICUData={ NULL }; +static UDataMemory commonICUData={ 0 }; static UBool setCommonICUData(UDataMemory *pData) { @@ -810,15 +811,19 @@ static void checkCommonData(UDataMemory *udm, UErrorCode *err) { } -U_CAPI void U_EXPORT2 +U_CAPI UBool U_EXPORT2 udata_cleanup() { + umtx_lock(NULL); if (gHashTable) { /* Delete the cache of user data mappings. */ uhash_close(gHashTable); /* Table owns the contents, and will delete them. */ gHashTable = 0; /* Cleanup is not thread safe. */ } udata_close(&commonICUData); /* Clean up common ICU Data */ + umtx_unlock(NULL); + + return TRUE; /* Everything was cleaned up */ } @@ -1021,7 +1026,7 @@ static UBool extendICUData() } umtx_unlock(NULL); - return U_SUCCESS(???); + return TRUE; /* SUCCESS? */ #endif /* OS390 */ } @@ -1085,19 +1090,19 @@ udata_setAppData(const char *path, const void *data, UErrorCode *err) udm.pHeader = data; checkCommonData(&udm, err); udata_cacheDataItem(path, &udm, err); -}; +} -/*------------------------------------------------------------------------------* - * * - * checkDataItem Given a freshly located/loaded data item, either * - * an entry in a common file or a separately loaded file, * - * sanity check its header, and see if the data is * - * acceptable to the app. * - * If the data is good, create and return a UDataMemory * - * object that can be returned to the application. * - * Return NULL on any sort of failure. * - * * - *------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------* + * * + * checkDataItem Given a freshly located/loaded data item, either * + * an entry in a common file or a separately loaded file, * + * sanity check its header, and see if the data is * + * acceptable to the app. * + * If the data is good, create and return a UDataMemory * + * object that can be returned to the application. * + * Return NULL on any sort of failure. * + * * + *----------------------------------------------------------------------------*/ static UDataMemory * checkDataItem ( diff --git a/icu4c/source/common/unicode/udata.h b/icu4c/source/common/unicode/udata.h index 759cf2f8d41..588186c5b9e 100644 --- a/icu4c/source/common/unicode/udata.h +++ b/icu4c/source/common/unicode/udata.h @@ -289,20 +289,6 @@ udata_setCommonData(const void *data, UErrorCode *err); U_CAPI void U_EXPORT2 udata_setAppData(const char *path, const void *data, UErrorCode *err); -/** - * Clean-up function for allocated memory and any other resources owned - * by udata. Deletes all such items. Everything is returned to its initial - * state. - * - * This function is called by . Applicataions normally - * have no reason to call it directly. - * - * @draft - */ -U_CAPI void U_EXPORT2 -udata_cleanup(); - - U_CDECL_END #endif