mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-12614 DateFormatSymbols resource bundle data loading update. Fix memory leak.
X-SVN-Rev: 38971
This commit is contained in:
parent
f79d0641e7
commit
578ec591e0
1 changed files with 8 additions and 3 deletions
|
@ -1519,7 +1519,7 @@ struct CalendarDataSink : public ResourceSink {
|
|||
// Initializes CalendarDataSink with default values
|
||||
CalendarDataSink(UErrorCode& status)
|
||||
: arrays(FALSE, status), arraySizes(FALSE, status), maps(FALSE, status),
|
||||
mapRefs(uprv_deleteUObject, NULL, 10, status),
|
||||
mapRefs(deleteHashtable, NULL, 10, status),
|
||||
aliasPathPairs(uprv_deleteUObject, uhash_compareUnicodeString, status),
|
||||
currentCalendarType(), nextCalendarType(),
|
||||
resourcesToVisit(NULL), aliasRelativePath() {
|
||||
|
@ -1836,6 +1836,11 @@ struct CalendarDataSink : public ResourceSink {
|
|||
static void deleteUnicodeStringArray(void *uArray) {
|
||||
delete[] static_cast<UnicodeString *>(uArray);
|
||||
}
|
||||
|
||||
// Deleter function to be used by 'maps'
|
||||
static void deleteHashtable(void *table) {
|
||||
delete static_cast<Hashtable *>(table);
|
||||
}
|
||||
};
|
||||
// Virtual destructors have to be defined out of line
|
||||
CalendarDataSink::~CalendarDataSink() {
|
||||
|
@ -1874,7 +1879,7 @@ initField(UnicodeString **field, int32_t& length, CalendarDataSink &sink, CharSt
|
|||
length = sink.arraySizes.geti(keyUString);
|
||||
*field = array;
|
||||
// DateFormatSymbols takes ownership of the array:
|
||||
sink.arrays.put(keyUString, NULL, status);
|
||||
sink.arrays.remove(keyUString);
|
||||
} else {
|
||||
length = 0;
|
||||
status = U_MISSING_RESOURCE_ERROR;
|
||||
|
@ -1892,7 +1897,7 @@ initField(UnicodeString **field, int32_t& length, CalendarDataSink &sink, CharSt
|
|||
int32_t arrayLength = sink.arraySizes.geti(keyUString);
|
||||
length = arrayLength + arrayOffset;
|
||||
*field = new UnicodeString[length];
|
||||
if (field == NULL) {
|
||||
if (*field == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue