From: Markus Scherer Date: Wed, 8 Aug 2012 00:50:16 +0000 (+0000) Subject: ICU-9434 use static_cast(void *) not reinterpret_cast X-Git-Tag: milestone-59-0-1~3687 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f6df5d520f6772d53b9b27dbdf6574166b132c5;p=icu ICU-9434 use static_cast(void *) not reinterpret_cast X-SVN-Rev: 32119 --- diff --git a/icu4c/source/common/bytestriebuilder.cpp b/icu4c/source/common/bytestriebuilder.cpp index b173ee89870..f252e2d41fe 100644 --- a/icu4c/source/common/bytestriebuilder.cpp +++ b/icu4c/source/common/bytestriebuilder.cpp @@ -179,9 +179,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 +253,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 +379,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); diff --git a/icu4c/source/common/bytestrieiterator.cpp b/icu4c/source/common/bytestrieiterator.cpp index d8318f6524f..e50f07c24fe 100644 --- a/icu4c/source/common/bytestrieiterator.cpp +++ b/icu4c/source/common/bytestrieiterator.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2010-2011, International Business Machines +* Copyright (C) 2010-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: bytestrieiterator.cpp @@ -22,7 +22,7 @@ U_NAMESPACE_BEGIN BytesTrie::Iterator::Iterator(const void *trieBytes, int32_t maxStringLength, UErrorCode &errorCode) - : bytes_(reinterpret_cast(trieBytes)), + : bytes_(static_cast(trieBytes)), pos_(bytes_), initialPos_(bytes_), remainingMatchLength_(-1), initialRemainingMatchLength_(-1), str_(NULL), maxLength_(maxStringLength), value_(0), stack_(NULL) { diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 36fab488495..0e5bdfbc22d 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -1511,7 +1511,7 @@ The leftmost codepage (.xxx) wins. if ((p = uprv_strchr(posixID, '.')) != NULL) { /* assume new locale can't be larger than old one? */ - correctedPOSIXLocale = reinterpret_cast(uprv_malloc(uprv_strlen(posixID)+1)); + correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID)+1)); /* Exit on memory allocation error. */ if (correctedPOSIXLocale == NULL) { return NULL; @@ -1528,7 +1528,7 @@ The leftmost codepage (.xxx) wins. /* Note that we scan the *uncorrected* ID. */ if ((p = uprv_strrchr(posixID, '@')) != NULL) { if (correctedPOSIXLocale == NULL) { - correctedPOSIXLocale = reinterpret_cast(uprv_malloc(uprv_strlen(posixID)+1)); + correctedPOSIXLocale = static_cast(uprv_malloc(uprv_strlen(posixID)+1)); /* Exit on memory allocation error. */ if (correctedPOSIXLocale == NULL) { return NULL; diff --git a/icu4c/source/common/ucharstriebuilder.cpp b/icu4c/source/common/ucharstriebuilder.cpp index 5ff120e7722..05255b48c9b 100644 --- a/icu4c/source/common/ucharstriebuilder.cpp +++ b/icu4c/source/common/ucharstriebuilder.cpp @@ -132,9 +132,9 @@ U_CDECL_BEGIN static int32_t U_CALLCONV compareElementStrings(const void *context, const void *left, const void *right) { - const UnicodeString *strings=reinterpret_cast(context); - const UCharsTrieElement *leftElement=reinterpret_cast(left); - const UCharsTrieElement *rightElement=reinterpret_cast(right); + const UnicodeString *strings=static_cast(context); + const UCharsTrieElement *leftElement=static_cast(left); + const UCharsTrieElement *rightElement=static_cast(right); return leftElement->compareStringTo(*rightElement, *strings); } @@ -210,7 +210,7 @@ UCharsTrieBuilder::buildUChars(UStringTrieBuildOption buildOption, UErrorCode &e } if(ucharsCapacity(uprv_malloc(capacity*2)); + uchars=static_cast(uprv_malloc(capacity*2)); if(uchars==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; ucharsCapacity=0; @@ -327,7 +327,7 @@ UCharsTrieBuilder::ensureCapacity(int32_t length) { do { newCapacity*=2; } while(newCapacity<=length); - UChar *newUChars=reinterpret_cast(uprv_malloc(newCapacity*2)); + UChar *newUChars=static_cast(uprv_malloc(newCapacity*2)); if(newUChars==NULL) { // unable to allocate memory uprv_free(uchars); diff --git a/icu4c/source/common/ucnv_io.cpp b/icu4c/source/common/ucnv_io.cpp index b846cb0e2f9..12d2b63f0d8 100644 --- a/icu4c/source/common/ucnv_io.cpp +++ b/icu4c/source/common/ucnv_io.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1999-2011, International Business Machines +* Copyright (C) 1999-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -854,13 +854,13 @@ ucnv_openStandardNames(const char *convName, if (listOffset < gMainTable.taggedAliasListsSize) { UAliasContext *myContext; - myEnum = reinterpret_cast(uprv_malloc(sizeof(UEnumeration))); + myEnum = static_cast(uprv_malloc(sizeof(UEnumeration))); if (myEnum == NULL) { *pErrorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } uprv_memcpy(myEnum, &gEnumAliases, sizeof(UEnumeration)); - myContext = reinterpret_cast(uprv_malloc(sizeof(UAliasContext))); + myContext = static_cast(uprv_malloc(sizeof(UAliasContext))); if (myContext == NULL) { *pErrorCode = U_MEMORY_ALLOCATION_ERROR; uprv_free(myEnum); @@ -1071,13 +1071,13 @@ ucnv_openAllNames(UErrorCode *pErrorCode) { if (haveAliasData(pErrorCode)) { uint16_t *myContext; - myEnum = reinterpret_cast(uprv_malloc(sizeof(UEnumeration))); + myEnum = static_cast(uprv_malloc(sizeof(UEnumeration))); if (myEnum == NULL) { *pErrorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } uprv_memcpy(myEnum, &gEnumAllConverters, sizeof(UEnumeration)); - myContext = reinterpret_cast(uprv_malloc(sizeof(uint16_t))); + myContext = static_cast(uprv_malloc(sizeof(uint16_t))); if (myContext == NULL) { *pErrorCode = U_MEMORY_ALLOCATION_ERROR; uprv_free(myEnum); diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 2f84aba5c48..39583abbafb 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -1525,7 +1525,7 @@ uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCod return NULL; } uprv_memcpy(result, &gKeywordsEnum, sizeof(UEnumeration)); - myContext = reinterpret_cast(uprv_malloc(sizeof(UKeywordsContext))); + myContext = static_cast(uprv_malloc(sizeof(UKeywordsContext))); if (myContext == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; uprv_free(result); @@ -2330,7 +2330,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult } if(n>=jSize) { if(j==smallBuffer) { /* overflowed the small buffer. */ - j = reinterpret_cast<_acceptLangItem *>(uprv_malloc(sizeof(j[0])*(jSize*2))); + j = static_cast<_acceptLangItem *>(uprv_malloc(sizeof(j[0])*(jSize*2))); if(j!=NULL) { uprv_memcpy(j,smallBuffer,sizeof(j[0])*jSize); } @@ -2338,7 +2338,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult fprintf(stderr,"malloced at size %d\n", jSize); #endif } else { - j = reinterpret_cast<_acceptLangItem *>(uprv_realloc(j, sizeof(j[0])*jSize*2)); + j = static_cast<_acceptLangItem *>(uprv_realloc(j, sizeof(j[0])*jSize*2)); #if defined(ULOC_DEBUG) fprintf(stderr,"re-alloced at size %d\n", jSize); #endif @@ -2360,7 +2360,7 @@ uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable, UAcceptResult } return -1; } - strs = reinterpret_cast(uprv_malloc((size_t)(sizeof(strs[0])*n))); + strs = static_cast(uprv_malloc((size_t)(sizeof(strs[0])*n))); /* Check for null pointer */ if (strs == NULL) { uprv_free(j); /* Free to avoid memory leak */ @@ -2405,7 +2405,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable, if(U_FAILURE(*status)) { return -1; } - fallbackList = reinterpret_cast(uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount))); + fallbackList = static_cast(uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount))); if(fallbackList==NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return -1; diff --git a/icu4c/source/common/unicode/bytestrie.h b/icu4c/source/common/unicode/bytestrie.h index a5a9cbc4dc3..9c7782740db 100644 --- a/icu4c/source/common/unicode/bytestrie.h +++ b/icu4c/source/common/unicode/bytestrie.h @@ -62,7 +62,7 @@ public: * @stable ICU 4.8 */ BytesTrie(const void *trieBytes) - : ownedArray_(NULL), bytes_(reinterpret_cast(trieBytes)), + : ownedArray_(NULL), bytes_(static_cast(trieBytes)), pos_(bytes_), remainingMatchLength_(-1) {} /** @@ -349,8 +349,8 @@ private: * This constructor is only called by the builder. */ BytesTrie(void *adoptBytes, const void *trieBytes) - : ownedArray_(reinterpret_cast(adoptBytes)), - bytes_(reinterpret_cast(trieBytes)), + : ownedArray_(static_cast(adoptBytes)), + bytes_(static_cast(trieBytes)), pos_(bytes_), remainingMatchLength_(-1) {} // No assignment operator. diff --git a/icu4c/source/common/uobject.cpp b/icu4c/source/common/uobject.cpp index bf31c573ce2..1d8f6dcb555 100644 --- a/icu4c/source/common/uobject.cpp +++ b/icu4c/source/common/uobject.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2002-2011, International Business Machines +* Copyright (C) 2002-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -115,5 +115,5 @@ U_NAMESPACE_USE U_CAPI void U_EXPORT2 uprv_deleteUObject(void *obj) { - delete reinterpret_cast(obj); + delete static_cast(obj); } diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index ea649eaa43f..64498ecbb21 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -2326,7 +2326,7 @@ ures_openAvailableLocales(const char *path, UErrorCode *status) if(U_FAILURE(*status)) { return NULL; } - myContext = reinterpret_cast(uprv_malloc(sizeof(ULocalesContext))); + myContext = static_cast(uprv_malloc(sizeof(ULocalesContext))); en = (UEnumeration *)uprv_malloc(sizeof(UEnumeration)); if(!en || !myContext) { *status = U_MEMORY_ALLOCATION_ERROR; diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 608524228d7..882a3873792 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -305,7 +305,7 @@ void collIterate::appendOffset(int32_t offset, UErrorCode &errorCode) { U_ASSERT(length >= offsetBufferSize || offsetStore != NULL); if(length >= offsetBufferSize) { int32_t newCapacity = 2 * offsetBufferSize + UCOL_EXPAND_CE_BUFFER_SIZE; - int32_t *newBuffer = reinterpret_cast(uprv_malloc(newCapacity * 4)); + int32_t *newBuffer = static_cast(uprv_malloc(newCapacity * 4)); if(newBuffer == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return; diff --git a/icu4c/source/tools/genrb/parse.cpp b/icu4c/source/tools/genrb/parse.cpp index 93957f6056c..082b5f18cee 100644 --- a/icu4c/source/tools/genrb/parse.cpp +++ b/icu4c/source/tools/genrb/parse.cpp @@ -262,7 +262,7 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin return NULL; } - result = reinterpret_cast(uprv_malloc(count+1)); + result = static_cast(uprv_malloc(count+1)); if (result == NULL) { @@ -1477,7 +1477,7 @@ parseBinary(ParseState* state, char *tag, uint32_t startline, const struct UStri count = (uint32_t)uprv_strlen(string); if (count > 0){ if((count % 2)==0){ - value = reinterpret_cast(uprv_malloc(sizeof(uint8_t) * count)); + value = static_cast(uprv_malloc(sizeof(uint8_t) * count)); if (value == NULL) { diff --git a/icu4c/source/tools/toolutil/swapimpl.cpp b/icu4c/source/tools/toolutil/swapimpl.cpp index 5b67b0fd524..f3364b96f7e 100644 --- a/icu4c/source/tools/toolutil/swapimpl.cpp +++ b/icu4c/source/tools/toolutil/swapimpl.cpp @@ -84,7 +84,7 @@ upname_swap(const UDataSwapper *ds, /* check data format and format version */ const UDataInfo *pInfo= reinterpret_cast( - reinterpret_cast(inData)+4); + static_cast(inData)+4); if(!( pInfo->dataFormat[0]==0x70 && /* dataFormat="pnam" */ pInfo->dataFormat[1]==0x6e && @@ -100,8 +100,8 @@ upname_swap(const UDataSwapper *ds, return 0; } - const uint8_t *inBytes=reinterpret_cast(inData)+headerSize; - uint8_t *outBytes=reinterpret_cast(outData)+headerSize; + const uint8_t *inBytes=static_cast(inData)+headerSize; + uint8_t *outBytes=static_cast(outData)+headerSize; if(length>=0) { length-=headerSize;