X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..249c4c5ea9376c24572daf9c2effa7484a282f14:/icuSources/common/bytestriebuilder.cpp?ds=sidebyside diff --git a/icuSources/common/bytestriebuilder.cpp b/icuSources/common/bytestriebuilder.cpp index c105dfec..581505e0 100644 --- a/icuSources/common/bytestriebuilder.cpp +++ b/icuSources/common/bytestriebuilder.cpp @@ -1,10 +1,12 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* -* Copyright (C) 2010-2011, International Business Machines +* Copyright (C) 2010-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: bytestriebuilder.cpp -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -35,7 +37,7 @@ class BytesTrieElement : public UMemory { public: // Use compiler's default constructor, initializes nothing. - void setTo(const StringPiece &s, int32_t val, CharString &strings, UErrorCode &errorCode); + void setTo(StringPiece s, int32_t val, CharString &strings, UErrorCode &errorCode); StringPiece getString(const CharString &strings) const { int32_t offset=stringOffset; @@ -86,7 +88,7 @@ private: }; void -BytesTrieElement::setTo(const StringPiece &s, int32_t val, +BytesTrieElement::setTo(StringPiece s, int32_t val, CharString &strings, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; @@ -143,7 +145,7 @@ BytesTrieBuilder::~BytesTrieBuilder() { } BytesTrieBuilder & -BytesTrieBuilder::add(const StringPiece &s, int32_t value, UErrorCode &errorCode) { +BytesTrieBuilder::add(StringPiece s, int32_t value, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return *this; } @@ -165,7 +167,7 @@ BytesTrieBuilder::add(const StringPiece &s, int32_t value, UErrorCode &errorCode return *this; // error instead of dereferencing null } if(elementsLength>0) { - uprv_memcpy(newElements, elements, elementsLength*sizeof(BytesTrieElement)); + uprv_memcpy(newElements, elements, (size_t)elementsLength*sizeof(BytesTrieElement)); } delete[] elements; elements=newElements; @@ -179,9 +181,9 @@ U_CDECL_BEGIN static int32_t U_CALLCONV compareElementStrings(const void *context, const void *left, const void *right) { - const CharString *strings=reinterpret_cast(context); - const BytesTrieElement *leftElement=reinterpret_cast(left); - const BytesTrieElement *rightElement=reinterpret_cast(right); + const CharString *strings=static_cast(context); + const BytesTrieElement *leftElement=static_cast(left); + const BytesTrieElement *rightElement=static_cast(right); return leftElement->compareStringTo(*rightElement, *strings); } @@ -253,7 +255,7 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err } if(bytesCapacity(uprv_malloc(capacity)); + bytes=static_cast(uprv_malloc(capacity)); if(bytes==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; bytesCapacity=0; @@ -379,7 +381,7 @@ BytesTrieBuilder::ensureCapacity(int32_t length) { do { newCapacity*=2; } while(newCapacity<=length); - char *newBytes=reinterpret_cast(uprv_malloc(newCapacity)); + char *newBytes=static_cast(uprv_malloc(newCapacity)); if(newBytes==NULL) { // unable to allocate memory uprv_free(bytes); @@ -430,9 +432,9 @@ BytesTrieBuilder::writeValueAndFinal(int32_t i, UBool isFinal) { int32_t length=1; if(i<0 || i>0xffffff) { intBytes[0]=(char)BytesTrie::kFiveByteValueLead; - intBytes[1]=(char)(i>>24); - intBytes[2]=(char)(i>>16); - intBytes[3]=(char)(i>>8); + intBytes[1]=(char)((uint32_t)i>>24); + intBytes[2]=(char)((uint32_t)i>>16); + intBytes[3]=(char)((uint32_t)i>>8); intBytes[4]=(char)i; length=5; // } else if(i<=BytesTrie::kMaxOneByteValue) {