ICU-9434 use static_cast<pointer type>(void *) not reinterpret_cast

X-SVN-Rev: 32119
This commit is contained in:
Markus Scherer 2012-08-08 00:50:16 +00:00
parent 1bf3f6e295
commit 2f6df5d520
12 changed files with 36 additions and 36 deletions

View 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);

View 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) {

View 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;

View 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);

View 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);

View 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;

View 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.

View 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);
}

View 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;

View 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;

View 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)
{

View 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;