From 93180d2d736f32e420c7009bcdde770aacc3f8ee Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" <srl@icu-project.org> Date: Wed, 31 Aug 2016 23:36:19 +0000 Subject: [PATCH] ICU-12704 change dtptngen.cpp to use LocalMemory<int32_t> instead of LocalArray LocalArray cannot be used with primitive types. X-SVN-Rev: 39114 --- icu4c/source/i18n/dtptngen.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index 6196803b72c..e680ee4f884 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -445,21 +445,23 @@ struct AllowedHourFormatsSink : public ResourceSink { if (U_FAILURE(errorCode)) { return; } for (int32_t j = 0; formatList.getKeyAndValue(j, key, value); ++j) { if (uprv_strcmp(key, "allowed") == 0) { // Ignore "preferred" list. - LocalArray<int32_t> list; + LocalMemory<int32_t> list; int32_t length; if (value.getType() == URES_STRING) { - list.adoptInsteadAndCheckErrorCode( - static_cast<int32_t *>(uprv_malloc(2 * sizeof(int32_t))), errorCode); - if (U_FAILURE(errorCode)) { return; } + if (list.allocateInsteadAndReset(2) == NULL) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } list[0] = getHourFormatFromUnicodeString(value.getUnicodeString(errorCode)); length = 1; } else { ResourceArray allowedFormats = value.getArray(errorCode); length = allowedFormats.getSize(); - list.adoptInsteadAndCheckErrorCode( - static_cast<int32_t *>(uprv_malloc((length + 1) * sizeof(int32_t))), errorCode); - if (U_FAILURE(errorCode)) { return; } - for (int32_t k = 0; k < length; ++k) { + if (list.allocateInsteadAndReset(length+1) == NULL) { + errorCode = U_MEMORY_ALLOCATION_ERROR; + return; + } + for (int32_t k = 0; k < length; ++k) { allowedFormats.getValue(k, value); list[k] = getHourFormatFromUnicodeString(value.getUnicodeString(errorCode)); } -- 2.40.0