ICU-5990 Use of a reference to a resource bundle string for tzid in meta-to-olson mapping table. Set NULL to the static global ZoneStringFormat cache. Added a code to prevent Purify to generate UMR warnings.
X-SVN-Rev: 23031
This commit is contained in:
parent
15733e3e0e
commit
40a1b853e2
@ -91,7 +91,6 @@ deleteOlsonToMetaMappingEntry(void *obj) {
|
||||
static void U_CALLCONV
|
||||
deleteMetaToOlsonMappingEntry(void *obj) {
|
||||
U_NAMESPACE_QUALIFIER MetaToOlsonMappingEntry *entry = (U_NAMESPACE_QUALIFIER MetaToOlsonMappingEntry*)obj;
|
||||
uprv_free(entry->id);
|
||||
uprv_free(entry->territory);
|
||||
uprv_free(entry);
|
||||
}
|
||||
@ -293,7 +292,7 @@ ZoneMeta::createCanonicalMap(void) {
|
||||
}
|
||||
u_charsToUChars(tzid, entry->id, tzidLen + 1);
|
||||
|
||||
if (territory == NULL || u_strcmp(territory, gWorld) == 0) {
|
||||
if (territory == NULL || u_strcmp(territory, gWorld) == 0) {
|
||||
entry->country = NULL;
|
||||
} else {
|
||||
entry->country = territory;
|
||||
@ -706,19 +705,10 @@ ZoneMeta::createMetaToOlsonMap(void) {
|
||||
ures_close(mz);
|
||||
goto error_cleanup;
|
||||
}
|
||||
entry->id = (UChar*)uprv_malloc((tzidLen + 1) * sizeof(UChar));
|
||||
if (entry->id == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(entry);
|
||||
ures_close(mz);
|
||||
goto error_cleanup;
|
||||
}
|
||||
u_strcpy(entry->id, tzid);
|
||||
|
||||
entry->id = tzid;
|
||||
entry->territory = (UChar*)uprv_malloc((territoryLen + 1) * sizeof(UChar));
|
||||
if (entry->territory == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(entry->id);
|
||||
uprv_free(entry);
|
||||
ures_close(mz);
|
||||
goto error_cleanup;
|
||||
|
@ -28,7 +28,7 @@ typedef struct OlsonToMetaMappingEntry {
|
||||
} OlsonToMetaMappingEntry;
|
||||
|
||||
typedef struct MetaToOlsonMappingEntry {
|
||||
UChar *id;
|
||||
const UChar *id; // const because it's a reference to a resource bundle string.
|
||||
UChar *territory;
|
||||
} MetaToOlsonMappingEntry;
|
||||
|
||||
|
@ -45,6 +45,7 @@ static UBool U_CALLCONV zoneStringFormat_cleanup(void)
|
||||
delete gZoneStringFormatCache;
|
||||
gZoneStringFormatCache = NULL;
|
||||
}
|
||||
gZoneStringFormatCache = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -582,6 +583,12 @@ ZoneStringFormat::ZoneStringFormat(const Locale &locale, UErrorCode &status)
|
||||
if (U_FAILURE(status)) {
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
// Workaround for reducing UMR warning in Purify.
|
||||
// Append NULL before calling getTerminatedBuffer()
|
||||
int32_t locLen = location.length();
|
||||
location.append((UChar)0).truncate(locLen);
|
||||
|
||||
zstrarray[ZSIDX_LOCATION] = location.getTerminatedBuffer();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user