ICU-9598 Respond to Markus' comments on C genderInfo
X-SVN-Rev: 32606
This commit is contained in:
parent
e899f6a44e
commit
bb296a6003
@ -53,10 +53,6 @@ static UBool U_CALLCONV gender_cleanup(void) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void U_CALLCONV deleteChars(void* chars) {
|
||||
uprv_free(chars);
|
||||
}
|
||||
|
||||
U_CDECL_END
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
@ -93,7 +89,7 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
|
||||
delete [] gObjs;
|
||||
return NULL;
|
||||
}
|
||||
uhash_setKeyDeleter(gGenderInfoCache, deleteChars);
|
||||
uhash_setKeyDeleter(gGenderInfoCache, uprv_free);
|
||||
ucln_i18n_registerCleanup(UCLN_I18N_GENDERINFO, gender_cleanup);
|
||||
}
|
||||
}
|
||||
@ -110,6 +106,9 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
|
||||
|
||||
// On cache miss, try to create GenderInfo from CLDR data
|
||||
result = loadInstance(locale, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Try to put our GenderInfo object in cache. If there is a race condition,
|
||||
// favor the GenderInfo object that is already in the cache.
|
||||
@ -119,10 +118,8 @@ const GenderInfo* GenderInfo::getInstance(const Locale& locale, UErrorCode& stat
|
||||
if (temp) {
|
||||
result = temp;
|
||||
} else {
|
||||
char* keyDup = uprv_strdup(key);
|
||||
uhash_put(gGenderInfoCache, keyDup, (void*) result, &status);
|
||||
uhash_put(gGenderInfoCache, uprv_strdup(key), (void*) result, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
uprv_free(keyDup);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE};
|
||||
|
||||
#define LENGTH(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||
#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
void addGendInfoForTest(TestNode** root);
|
||||
static void TestGenderInfo(void);
|
||||
@ -39,7 +39,7 @@ static void TestGenderInfo(void) {
|
||||
log_err("Fail to create UGenderInfo - %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
UGender actual = ugender_getListGender(actual_gi, kAllFemale, LENGTH(kAllFemale), &status);
|
||||
UGender actual = ugender_getListGender(actual_gi, kAllFemale, LENGTHOF(kAllFemale), &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("Fail to get gender of list - %s\n", u_errorName(status));
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user