From 966d01b596104a5dda84b1c190beb0ad856bec2a Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Thu, 13 Jun 2002 16:43:41 +0000 Subject: [PATCH] ICU-1896 Flush the available converter names when the converter cache is flushed. X-SVN-Rev: 8870 --- icu4c/source/common/ucnv_bld.c | 2 ++ icu4c/source/common/ucnv_io.c | 17 ++++++++++++----- icu4c/source/common/ucnv_io.h | 8 ++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/icu4c/source/common/ucnv_bld.c b/icu4c/source/common/ucnv_bld.c index eb65b9c4c6a..c886c68e49c 100644 --- a/icu4c/source/common/ucnv_bld.c +++ b/icu4c/source/common/ucnv_bld.c @@ -598,6 +598,8 @@ ucnv_flushCache () } umtx_unlock (&cnvCacheMutex); + ucnv_io_flushAvailableConverterCache(); + return tableDeletedNum; } diff --git a/icu4c/source/common/ucnv_io.c b/icu4c/source/common/ucnv_io.c index 24f49bbe505..26a064852be 100644 --- a/icu4c/source/common/ucnv_io.c +++ b/icu4c/source/common/ucnv_io.c @@ -173,11 +173,7 @@ ucnv_io_cleanup() aliasData = NULL; } - if (availableConverters) { - uprv_free((char **)availableConverters); - availableConverters = NULL; - } - availableConverterCount = 0; + ucnv_io_flushAvailableConverterCache(); aliasData = NULL; aliasTable = NULL; @@ -406,6 +402,17 @@ ucnv_getStandardName(const char *alias, const char *standard, UErrorCode *pError return NULL; } +void +ucnv_io_flushAvailableConverterCache() { + if (availableConverters) { + umtx_lock(NULL); + uprv_free((char **)availableConverters); + availableConverters = NULL; + umtx_unlock(NULL); + } + availableConverterCount = 0; +} + static void ucnv_io_loadAvailableConverterList(void) { uint16_t idx = 0; uint16_t localConverterCount = 0; diff --git a/icu4c/source/common/ucnv_io.h b/icu4c/source/common/ucnv_io.h index 752e7f1cece..500718dee06 100644 --- a/icu4c/source/common/ucnv_io.h +++ b/icu4c/source/common/ucnv_io.h @@ -71,6 +71,14 @@ ucnv_io_getAvailableConverter(uint16_t n, UErrorCode *pErrorCode); U_CFUNC void ucnv_io_fillAvailableConverters(const char **aliases, UErrorCode *pErrorCode); +/** + * Return the (n)th converter name in mixed case, or NULL + * if there is none (typically, if the data cannot be loaded). + * 0<=index