]> granicus.if.org Git - icu/commitdiff
ICU-9434 use static_cast<pointer type>(void *) not reinterpret_cast
authorMarkus Scherer <markus.icu@gmail.com>
Wed, 8 Aug 2012 00:50:16 +0000 (00:50 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Wed, 8 Aug 2012 00:50:16 +0000 (00:50 +0000)
X-SVN-Rev: 32119

12 files changed:
icu4c/source/common/bytestriebuilder.cpp
icu4c/source/common/bytestrieiterator.cpp
icu4c/source/common/putil.cpp
icu4c/source/common/ucharstriebuilder.cpp
icu4c/source/common/ucnv_io.cpp
icu4c/source/common/uloc.cpp
icu4c/source/common/unicode/bytestrie.h
icu4c/source/common/uobject.cpp
icu4c/source/common/uresbund.cpp
icu4c/source/i18n/ucol.cpp
icu4c/source/tools/genrb/parse.cpp
icu4c/source/tools/toolutil/swapimpl.cpp

index b173ee898700d01a360716022796769f013071b5..f252e2d41fe5d794502111606cf63523cde32fd5 100644 (file)
@@ -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<const CharString *>(context);
-    const BytesTrieElement *leftElement=reinterpret_cast<const BytesTrieElement *>(left);
-    const BytesTrieElement *rightElement=reinterpret_cast<const BytesTrieElement *>(right);
+    const CharString *strings=static_cast<const CharString *>(context);
+    const BytesTrieElement *leftElement=static_cast<const BytesTrieElement *>(left);
+    const BytesTrieElement *rightElement=static_cast<const BytesTrieElement *>(right);
     return leftElement->compareStringTo(*rightElement, *strings);
 }
 
@@ -253,7 +253,7 @@ BytesTrieBuilder::buildBytes(UStringTrieBuildOption buildOption, UErrorCode &err
     }
     if(bytesCapacity<capacity) {
         uprv_free(bytes);
-        bytes=reinterpret_cast<char *>(uprv_malloc(capacity));
+        bytes=static_cast<char *>(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<char *>(uprv_malloc(newCapacity));
+        char *newBytes=static_cast<char *>(uprv_malloc(newCapacity));
         if(newBytes==NULL) {
             // unable to allocate memory
             uprv_free(bytes);
index d8318f6524f9670830edae3dc2befee6e08af94f..e50f07c24fee650881a300d2ecef9de3d8b72670 100644 (file)
@@ -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<const uint8_t *>(trieBytes)),
+        : bytes_(static_cast<const uint8_t *>(trieBytes)),
           pos_(bytes_), initialPos_(bytes_),
           remainingMatchLength_(-1), initialRemainingMatchLength_(-1),
           str_(NULL), maxLength_(maxStringLength), value_(0), stack_(NULL) {
index 36fab488495a6eea600c8ca2269ecee8322102cc..0e5bdfbc22df8e86850a57cdcc43cb799e3e53cd 100644 (file)
@@ -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<char *>(uprv_malloc(uprv_strlen(posixID)+1));
+        correctedPOSIXLocale = static_cast<char *>(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<char *>(uprv_malloc(uprv_strlen(posixID)+1));
+            correctedPOSIXLocale = static_cast<char *>(uprv_malloc(uprv_strlen(posixID)+1));
             /* Exit on memory allocation error. */
             if (correctedPOSIXLocale == NULL) {
                 return NULL;
index 5ff120e772270586a30d367aa2ff4955a407d975..05255b48c9b3c88323defb5fa0ee45c9ad6ef25b 100644 (file)
@@ -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<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);
 }
 
@@ -210,7 +210,7 @@ UCharsTrieBuilder::buildUChars(UStringTrieBuildOption buildOption, UErrorCode &e
     }
     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;
@@ -327,7 +327,7 @@ UCharsTrieBuilder::ensureCapacity(int32_t length) {
         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);
index b846cb0e2f91bd3a06d58c6cb603691a902cdebb..12d2b63f0d8cbbf551e7928305425335cfabccfa 100644 (file)
@@ -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<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
+            myEnum = static_cast<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
             if (myEnum == NULL) {
                 *pErrorCode = U_MEMORY_ALLOCATION_ERROR;
                 return NULL;
             }
             uprv_memcpy(myEnum, &gEnumAliases, sizeof(UEnumeration));
-            myContext = reinterpret_cast<UAliasContext *>(uprv_malloc(sizeof(UAliasContext)));
+            myContext = static_cast<UAliasContext *>(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<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
+        myEnum = static_cast<UEnumeration *>(uprv_malloc(sizeof(UEnumeration)));
         if (myEnum == NULL) {
             *pErrorCode = U_MEMORY_ALLOCATION_ERROR;
             return NULL;
         }
         uprv_memcpy(myEnum, &gEnumAllConverters, sizeof(UEnumeration));
-        myContext = reinterpret_cast<uint16_t *>(uprv_malloc(sizeof(uint16_t)));
+        myContext = static_cast<uint16_t *>(uprv_malloc(sizeof(uint16_t)));
         if (myContext == NULL) {
             *pErrorCode = U_MEMORY_ALLOCATION_ERROR;
             uprv_free(myEnum);
index 2f84aba5c48b52998dae3413cf720a0d1772216e..39583abbafb2c4128abcc47a0c1ffaae3f5ea4b0 100644 (file)
@@ -1525,7 +1525,7 @@ uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCod
         return NULL;
     }
     uprv_memcpy(result, &gKeywordsEnum, sizeof(UEnumeration));
-    myContext = reinterpret_cast<UKeywordsContext *>(uprv_malloc(sizeof(UKeywordsContext)));
+    myContext = static_cast<UKeywordsContext *>(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<char **>(uprv_malloc((size_t)(sizeof(strs[0])*n)));
+    strs = static_cast<char **>(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<char **>(uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount)));
+    fallbackList = static_cast<char **>(uprv_malloc((size_t)(sizeof(fallbackList[0])*acceptListCount)));
     if(fallbackList==NULL) {
         *status = U_MEMORY_ALLOCATION_ERROR;
         return -1;
index a5a9cbc4dc36a5157f2ffcc9baffd5ee01f0b7b6..9c7782740dba2752b1f01264d3977ee615402007 100644 (file)
@@ -62,7 +62,7 @@ public:
      * @stable ICU 4.8
      */
     BytesTrie(const void *trieBytes)
-            : ownedArray_(NULL), bytes_(reinterpret_cast<const uint8_t *>(trieBytes)),
+            : ownedArray_(NULL), bytes_(static_cast<const uint8_t *>(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<uint8_t *>(adoptBytes)),
-              bytes_(reinterpret_cast<const uint8_t *>(trieBytes)),
+            : ownedArray_(static_cast<uint8_t *>(adoptBytes)),
+              bytes_(static_cast<const uint8_t *>(trieBytes)),
               pos_(bytes_), remainingMatchLength_(-1) {}
 
     // No assignment operator.
index bf31c573ce27f9b5263423e83f2c0bd5df4093b5..1d8f6dcb555e488b37a88ad8c967d806a90144e5 100644 (file)
@@ -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<UObject *>(obj);
+    delete static_cast<UObject *>(obj);
 }
index ea649eaa43f29e0fc9ae8f0b48319d5e2f0ad818..64498ecbb21c019a7ecea5435d50ee29a8f579e6 100644 (file)
@@ -2326,7 +2326,7 @@ ures_openAvailableLocales(const char *path, UErrorCode *status)
     if(U_FAILURE(*status)) {
         return NULL;
     }
-    myContext = reinterpret_cast<ULocalesContext *>(uprv_malloc(sizeof(ULocalesContext)));
+    myContext = static_cast<ULocalesContext *>(uprv_malloc(sizeof(ULocalesContext)));
     en =  (UEnumeration *)uprv_malloc(sizeof(UEnumeration));
     if(!en || !myContext) {
         *status = U_MEMORY_ALLOCATION_ERROR;
index 608524228d759dc9dbe331e45d9cc9c7be702cf4..882a38737927e4a4f5283597df507645265038d9 100644 (file)
@@ -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<int32_t *>(uprv_malloc(newCapacity * 4));
+        int32_t *newBuffer = static_cast<int32_t *>(uprv_malloc(newCapacity * 4));
         if(newBuffer == NULL) {
             errorCode = U_MEMORY_ALLOCATION_ERROR;
             return;
index 93957f6056c891cca4ca1fa80b5e1c13c2064295..082b5f18cee2549a888c6dc5298c9c61386d10f8 100644 (file)
@@ -262,7 +262,7 @@ static char *getInvariantString(ParseState* state, uint32_t *line, struct UStrin
         return NULL;
     }
 
-    result = reinterpret_cast<char *>(uprv_malloc(count+1));
+    result = static_cast<char *>(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<uint8_t *>(uprv_malloc(sizeof(uint8_t) * count));
+            value = static_cast<uint8_t *>(uprv_malloc(sizeof(uint8_t) * count));
 
             if (value == NULL)
             {
index 5b67b0fd524cd155bbe5e7cc6919464a5b9c0aef..f3364b96f7e86e423ea02b6b181edca824972a8d 100644 (file)
@@ -84,7 +84,7 @@ upname_swap(const UDataSwapper *ds,
     /* check data format and format version */
     const UDataInfo *pInfo=
         reinterpret_cast<const UDataInfo *>(
-            reinterpret_cast<const char *>(inData)+4);
+            static_cast<const char *>(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<const uint8_t *>(inData)+headerSize;
-    uint8_t *outBytes=reinterpret_cast<uint8_t *>(outData)+headerSize;
+    const uint8_t *inBytes=static_cast<const uint8_t *>(inData)+headerSize;
+    uint8_t *outBytes=static_cast<uint8_t *>(outData)+headerSize;
 
     if(length>=0) {
         length-=headerSize;