X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..4f1e1a09ce4daed860e35d359ce2fceccb0764e8:/icuSources/common/utrie2_builder.cpp diff --git a/icuSources/common/utrie2_builder.cpp b/icuSources/common/utrie2_builder.cpp index 8d2a4e12..d8a3a067 100644 --- a/icuSources/common/utrie2_builder.cpp +++ b/icuSources/common/utrie2_builder.cpp @@ -1,12 +1,14 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** * -* Copyright (C) 2001-2011, International Business Machines +* Copyright (C) 2001-2014, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** * file name: utrie2_builder.cpp -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -33,8 +35,6 @@ #include "utrie.h" /* for utrie2_fromUTrie() and utrie_swap() */ -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) - /* Implementation notes ----------------------------------------------------- */ /* @@ -250,11 +250,11 @@ cloneBuilder(const UNewTrie2 *other) { /* clone data */ uprv_memcpy(trie->index1, other->index1, sizeof(trie->index1)); - uprv_memcpy(trie->index2, other->index2, other->index2Length*4); + uprv_memcpy(trie->index2, other->index2, (size_t)other->index2Length*4); trie->index2NullOffset=other->index2NullOffset; trie->index2Length=other->index2Length; - uprv_memcpy(trie->data, other->data, other->dataLength*4); + uprv_memcpy(trie->data, other->data, (size_t)other->dataLength*4); trie->dataNullOffset=other->dataNullOffset; trie->dataLength=other->dataLength; @@ -262,7 +262,7 @@ cloneBuilder(const UNewTrie2 *other) { if(other->isCompacted) { trie->firstFreeBlock=0; } else { - uprv_memcpy(trie->map, other->map, (other->dataLength>>UTRIE2_SHIFT_2)*4); + uprv_memcpy(trie->map, other->map, ((size_t)other->dataLength>>UTRIE2_SHIFT_2)*4); trie->firstFreeBlock=other->firstFreeBlock; } @@ -476,7 +476,7 @@ allocIndex2Block(UNewTrie2 *trie) { newBlock=trie->index2Length; newTop=newBlock+UTRIE2_INDEX_2_BLOCK_LENGTH; - if(newTop>LENGTHOF(trie->index2)) { + if(newTop>UPRV_LENGTHOF(trie->index2)) { /* * Should never occur. * Either UTRIE2_MAX_BUILD_TIME_INDEX_LENGTH is incorrect, @@ -542,7 +542,7 @@ allocDataBlock(UNewTrie2 *trie, int32_t copyBlock) { if(data==NULL) { return -1; } - uprv_memcpy(data, trie->data, trie->dataLength*4); + uprv_memcpy(data, trie->data, (size_t)trie->dataLength*4); uprv_free(trie->data); trie->data=data; trie->dataCapacity=capacity; @@ -1404,7 +1404,7 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { /* write 32-bit data values */ trie->data16=NULL; trie->data32=(uint32_t *)dest16; - uprv_memcpy(dest16, newTrie->data, newTrie->dataLength*4); + uprv_memcpy(dest16, newTrie->data, (size_t)newTrie->dataLength*4); break; default: *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; @@ -1417,35 +1417,6 @@ utrie2_freeze(UTrie2 *trie, UTrie2ValueBits valueBits, UErrorCode *pErrorCode) { trie->newTrie=NULL; } -U_CAPI UBool U_EXPORT2 -utrie2_isFrozen(const UTrie2 *trie) { - return (UBool)(trie->newTrie==NULL); -} - -U_CAPI int32_t U_EXPORT2 -utrie2_serialize(UTrie2 *trie, - void *data, int32_t capacity, - UErrorCode *pErrorCode) { - /* argument check */ - if(U_FAILURE(*pErrorCode)) { - return 0; - } - - if( trie==NULL || trie->memory==NULL || trie->newTrie!=NULL || - capacity<0 || (capacity>0 && (data==NULL || (U_POINTER_MASK_LSB(data, 3)!=0))) - ) { - *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - - if(capacity>=trie->length) { - uprv_memcpy(data, trie->memory, trie->length); - } else { - *pErrorCode=U_BUFFER_OVERFLOW_ERROR; - } - return trie->length; -} - /* * This is here to avoid a dependency from utrie2.cpp on utrie.c. * This file already depends on utrie.c.