+// © 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: ucharstriebuilder.h
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
return *this;
}
if(elementsLength>0) {
- uprv_memcpy(newElements, elements, elementsLength*sizeof(UCharsTrieElement));
+ uprv_memcpy(newElements, elements, (size_t)elementsLength*sizeof(UCharsTrieElement));
}
delete[] elements;
elements=newElements;
static int32_t U_CALLCONV
compareElementStrings(const void *context, const void *left, const void *right) {
- const UnicodeString *strings=reinterpret_cast<const UnicodeString *>(context);
- const UCharsTrieElement *leftElement=reinterpret_cast<const UCharsTrieElement *>(left);
- const UCharsTrieElement *rightElement=reinterpret_cast<const UCharsTrieElement *>(right);
+ const UnicodeString *strings=static_cast<const UnicodeString *>(context);
+ const UCharsTrieElement *leftElement=static_cast<const UCharsTrieElement *>(left);
+ const UCharsTrieElement *rightElement=static_cast<const UCharsTrieElement *>(right);
return leftElement->compareStringTo(*rightElement, *strings);
}
}
if(ucharsCapacity<capacity) {
uprv_free(uchars);
- uchars=reinterpret_cast<UChar *>(uprv_malloc(capacity*2));
+ uchars=static_cast<UChar *>(uprv_malloc(capacity*2));
if(uchars==NULL) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
ucharsCapacity=0;
UCharsTrieBuilder::UCTLinearMatchNode::UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode)
: LinearMatchNode(len, nextNode), s(units) {
- hash=hash*37+ustr_hashUCharsN(units, len);
+ hash=hash*37u+ustr_hashUCharsN(units, len);
}
UBool
do {
newCapacity*=2;
} while(newCapacity<=length);
- UChar *newUChars=reinterpret_cast<UChar *>(uprv_malloc(newCapacity*2));
+ UChar *newUChars=static_cast<UChar *>(uprv_malloc(newCapacity*2));
if(newUChars==NULL) {
// unable to allocate memory
uprv_free(uchars);
int32_t length;
if(i<0 || i>UCharsTrie::kMaxTwoUnitValue) {
intUnits[0]=(UChar)(UCharsTrie::kThreeUnitValueLead);
- intUnits[1]=(UChar)(i>>16);
+ intUnits[1]=(UChar)((uint32_t)i>>16);
intUnits[2]=(UChar)i;
length=3;
// } else if(i<=UCharsTrie::kMaxOneUnitValue) {
int32_t length;
if(value<0 || value>UCharsTrie::kMaxTwoUnitNodeValue) {
intUnits[0]=(UChar)(UCharsTrie::kThreeUnitNodeValueLead);
- intUnits[1]=(UChar)(value>>16);
+ intUnits[1]=(UChar)((uint32_t)value>>16);
intUnits[2]=(UChar)value;
length=3;
} else if(value<=UCharsTrie::kMaxOneUnitNodeValue) {