mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-20482 Pickup fixes for memory problems and dependencies issues.
cherry-picked from: 0963829d4423329a63d7771740556404e32eb0c2
Original commit message:
Selectively cherry pick memory fixes and dependencies changes from ICU 63 RC BRS tasks.
(cherry-picked from: cc1784ae7d
)
This commit is contained in:
parent
cb46be28c0
commit
392534bd93
4 changed files with 12 additions and 8 deletions
|
@ -172,7 +172,7 @@ public:
|
|||
* @return *this
|
||||
*/
|
||||
LocalMemory<T> &moveFrom(LocalMemory<T> &src) U_NOEXCEPT {
|
||||
delete[] LocalPointerBase<T>::ptr;
|
||||
uprv_free(LocalPointerBase<T>::ptr);
|
||||
LocalPointerBase<T>::ptr=src.ptr;
|
||||
src.ptr=NULL;
|
||||
return *this;
|
||||
|
|
|
@ -99,7 +99,7 @@ static int32_t compareEncodedDateWithYMD(int encoded, int year, int month, int d
|
|||
}
|
||||
}
|
||||
|
||||
EraRules::EraRules(LocalArray<int32_t>& eraStartDates, int32_t numEras)
|
||||
EraRules::EraRules(LocalMemory<int32_t>& eraStartDates, int32_t numEras)
|
||||
: numEras(numEras) {
|
||||
startDates.moveFrom(eraStartDates);
|
||||
initCurrentEra();
|
||||
|
@ -124,8 +124,9 @@ EraRules* EraRules::createInstance(const char *calType, UBool includeTentativeEr
|
|||
int32_t numEras = ures_getSize(rb.getAlias());
|
||||
int32_t firstTentativeIdx = MAX_INT32;
|
||||
|
||||
LocalArray<int32_t> startDates(new int32_t[numEras], status);
|
||||
if (U_FAILURE(status)) {
|
||||
LocalMemory<int32_t> startDates(static_cast<int32_t *>(uprv_malloc(numEras * sizeof(int32_t))));
|
||||
if (startDates.isNull()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
uprv_memset(startDates.getAlias(), 0 , numEras * sizeof(int32_t));
|
||||
|
|
|
@ -8,18 +8,20 @@
|
|||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/localpointer.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "cmemory.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Export an explicit template instantiation of LocalArray used as a data member of EraRules.
|
||||
// Export an explicit template instantiation of LocalMemory used as a data member of EraRules.
|
||||
// When building DLLs for Windows this is required even though no direct access leaks out of the i18n library.
|
||||
// See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.
|
||||
#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
|
||||
// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
|
||||
#pragma warning(suppress: 4661)
|
||||
template class U_I18N_API LocalPointerBase<int32_t>;
|
||||
template class U_I18N_API LocalArray<int32_t>;
|
||||
template class U_I18N_API LocalMemory<int32_t>;
|
||||
#endif
|
||||
|
||||
class U_I18N_API EraRules : public UMemory {
|
||||
|
@ -76,11 +78,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
EraRules(LocalArray<int32_t>& eraStartDates, int32_t numEra);
|
||||
EraRules(LocalMemory<int32_t>& eraStartDates, int32_t numEra);
|
||||
|
||||
void initCurrentEra();
|
||||
|
||||
LocalArray<int32_t> startDates;
|
||||
LocalMemory<int32_t> startDates;
|
||||
int32_t numEras;
|
||||
int32_t currentEra;
|
||||
};
|
||||
|
|
|
@ -959,6 +959,7 @@ group: formatting
|
|||
tzfmt.o tzgnames.o tznames.o tznames_impl.o
|
||||
datefmt.o dtfmtsym.o dtitvfmt.o dtitvinf.o dtptngen.o dtrule.o reldtfmt.o reldatefmt.o
|
||||
smpdtfmt.o smpdtfst.o udateintervalformat.o udatpg.o windtfmt.o
|
||||
erarules.o # mostly for Japanese eras
|
||||
udat.o
|
||||
tmunit.o tmutamt.o tmutfmt.o
|
||||
# messageformat
|
||||
|
|
Loading…
Add table
Reference in a new issue