ICU-13676 Enabling cleanup of default converter whenever the default converter is put back into the global singleton cache.

X-SVN-Rev: 41314
This commit is contained in:
Shane Carr 2018-05-03 06:50:50 +00:00
parent 0a0d99ebc8
commit 530bad0b79
3 changed files with 13 additions and 4 deletions

View File

@ -261,6 +261,11 @@ static UBool U_CALLCONV ucnv_cleanup(void) {
return (SHARED_DATA_HASHTABLE == NULL);
}
U_CAPI void U_EXPORT2
ucnv_enableCleanup() {
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
}
static UBool U_CALLCONV
isCnvAcceptable(void * /*context*/,
const char * /*type*/, const char * /*name*/,
@ -439,7 +444,7 @@ ucnv_shareConverterData(UConverterSharedData * data)
SHARED_DATA_HASHTABLE = uhash_openSize(uhash_hashChars, uhash_compareChars, NULL,
ucnv_io_countKnownConverters(&err)*UCNV_CACHE_LOAD_FACTOR,
&err);
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
ucnv_enableCleanup();
if (U_FAILURE(err))
return;
@ -1099,7 +1104,7 @@ static void U_CALLCONV initAvailableConvertersList(UErrorCode &errCode) {
U_ASSERT(gAvailableConverterCount == 0);
U_ASSERT(gAvailableConverters == NULL);
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
ucnv_enableCleanup();
UEnumeration *allConvEnum = ucnv_openAllNames(&errCode);
int32_t allConverterCount = uenum_count(allConvEnum, &errCode);
if (U_FAILURE(errCode)) {
@ -1205,7 +1210,7 @@ internalSetName(const char *name, UErrorCode *status) {
// -- Andy
gDefaultConverterName = gDefaultConverterNameBuffer;
ucln_common_registerCleanup(UCLN_COMMON_UCNV, ucnv_cleanup);
ucnv_enableCleanup();
umtx_unlock(&cnvCacheMutex);
}

View File

@ -288,6 +288,9 @@ ucnv_swap(const UDataSwapper *ds,
const void *inData, int32_t length, void *outData,
UErrorCode *pErrorCode);
U_CAPI void U_EXPORT2
ucnv_enableCleanup();
#endif
#endif /* _UCNV_BLD */

View File

@ -28,6 +28,7 @@
#include "cmemory.h"
#include "umutex.h"
#include "ustr_cnv.h"
#include "ucnv_bld.h"
/* mutexed access to a shared default converter ----------------------------- */
@ -68,8 +69,8 @@ u_releaseDefaultConverter(UConverter *converter)
if (converter != NULL) {
ucnv_reset(converter);
}
ucnv_enableCleanup();
umtx_lock(NULL);
if(gDefaultConverter == NULL) {
gDefaultConverter = converter;
converter = NULL;