ICU-1962 use uprv_malloc/free instead of new/delete for non-class types
X-SVN-Rev: 9194
This commit is contained in:
parent
86b7c21c50
commit
30c37a9114
@ -48,11 +48,11 @@ BreakDictionary::BreakDictionary(const char* dictionaryFilename, UErrorCode& sta
|
||||
BreakDictionary::~BreakDictionary()
|
||||
{
|
||||
ucmp8_close(columnMap);
|
||||
delete [] table;
|
||||
delete [] rowIndex;
|
||||
delete [] rowIndexFlags;
|
||||
delete [] rowIndexFlagsIndex;
|
||||
delete [] rowIndexShifts;
|
||||
uprv_free(table);
|
||||
uprv_free(rowIndex);
|
||||
uprv_free(rowIndexFlags);
|
||||
uprv_free(rowIndexFlagsIndex);
|
||||
uprv_free(rowIndexShifts);
|
||||
}
|
||||
|
||||
// macros to support readDictionaryFile. The data files originated from a Java
|
||||
@ -102,7 +102,7 @@ BreakDictionary::readDictionaryFile(UMemoryStream* in)
|
||||
// read in the row-number index
|
||||
uprv_mstrm_read(in, &l, 4);
|
||||
SWAP32(l);
|
||||
rowIndex = new int16_t[l];
|
||||
rowIndex = (int16_t *)uprv_malloc(l*2);
|
||||
uprv_mstrm_read(in, rowIndex, l * sizeof (int16_t) );
|
||||
for (i = 0; i < l; i++) {
|
||||
SWAP16(rowIndex[i]);
|
||||
@ -111,14 +111,14 @@ BreakDictionary::readDictionaryFile(UMemoryStream* in)
|
||||
// load in the populated-cells bitmap: index first, then bitmap list
|
||||
uprv_mstrm_read(in, &l, 4);
|
||||
SWAP32(l);
|
||||
rowIndexFlagsIndex = new int16_t[l];
|
||||
rowIndexFlagsIndex = (int16_t *)uprv_malloc(l*2);
|
||||
uprv_mstrm_read(in, rowIndexFlagsIndex, l * sizeof(int16_t) );
|
||||
for (i = 0; i < l; i++) {
|
||||
SWAP16(rowIndexFlagsIndex[i]);
|
||||
}
|
||||
uprv_mstrm_read(in, &l, 4);
|
||||
SWAP32(l);
|
||||
rowIndexFlags = new int32_t[l];
|
||||
rowIndexFlags = (int32_t *)uprv_malloc(l*4);
|
||||
uprv_mstrm_read(in, rowIndexFlags, l * sizeof(int32_t));
|
||||
for (i = 0; i < l; i++) {
|
||||
SWAP32(rowIndexFlags[i]);
|
||||
@ -127,13 +127,13 @@ BreakDictionary::readDictionaryFile(UMemoryStream* in)
|
||||
// load in the row-shift index
|
||||
uprv_mstrm_read(in, &l, 4);
|
||||
SWAP32(l);
|
||||
rowIndexShifts = new int8_t[l];
|
||||
rowIndexShifts = (int8_t *)uprv_malloc(l);
|
||||
uprv_mstrm_read(in, rowIndexShifts, l);
|
||||
|
||||
// finally, load in the actual state table
|
||||
uprv_mstrm_read(in, &l, 4);
|
||||
SWAP32(l);
|
||||
table = new int16_t[l];
|
||||
table = (int16_t *)uprv_malloc(l*2);
|
||||
uprv_mstrm_read(in, table, l * sizeof(int16_t) );
|
||||
for (i = 0; i < l; i++) {
|
||||
SWAP16(table[i]);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "cmemory.h"
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// class CharString
|
||||
@ -57,7 +58,7 @@ inline CharString::CharString(const UnicodeString& str) {
|
||||
// TODO This isn't quite right -- we should probably do
|
||||
// preflighting here to determine the real length.
|
||||
if (str.length() >= (int32_t)sizeof(buf)) {
|
||||
ptr = new char[str.length() + 8];
|
||||
ptr = (char *)uprv_malloc(str.length() + 8);
|
||||
} else {
|
||||
ptr = buf;
|
||||
}
|
||||
@ -66,7 +67,7 @@ inline CharString::CharString(const UnicodeString& str) {
|
||||
|
||||
inline CharString::~CharString() {
|
||||
if (ptr != buf) {
|
||||
delete[] ptr;
|
||||
uprv_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,20 +110,25 @@ void
|
||||
Normalizer::init(CharacterIterator *iter) {
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
|
||||
text=new UCharIterator;
|
||||
|
||||
if(unorm_haveData(&errorCode)) {
|
||||
uiter_setCharacterIterator(text, iter);
|
||||
text=(UCharIterator *)uprv_malloc(sizeof(UCharIterator));
|
||||
if(text!=NULL) {
|
||||
if(unorm_haveData(&errorCode)) {
|
||||
uiter_setCharacterIterator(text, iter);
|
||||
} else {
|
||||
delete iter;
|
||||
uiter_setCharacterIterator(text, new UCharCharacterIterator(&_NUL, 0));
|
||||
}
|
||||
} else {
|
||||
delete iter;
|
||||
uiter_setCharacterIterator(text, new UCharCharacterIterator(&_NUL, 0));
|
||||
}
|
||||
}
|
||||
|
||||
Normalizer::~Normalizer()
|
||||
{
|
||||
delete (CharacterIterator *)text->context;
|
||||
delete text;
|
||||
if(text!=NULL) {
|
||||
delete (CharacterIterator *)text->context;
|
||||
uprv_free(text);
|
||||
}
|
||||
}
|
||||
|
||||
Normalizer*
|
||||
@ -300,7 +305,7 @@ Normalizer::concatenate(UnicodeString &left, UnicodeString &right,
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the current character in the normalized text->
|
||||
* Return the current character in the normalized text.
|
||||
*/
|
||||
UChar32 Normalizer::current() {
|
||||
if(bufferPos<buffer.length() || nextNormalize()) {
|
||||
|
@ -633,7 +633,7 @@ static void U_EXPORT2 U_CALLCONV RBBISetTable_deleter(void *p) {
|
||||
delete px->key;
|
||||
// Note: px->val is owned by the linked list "fSetsListHead" in scanner.
|
||||
// Don't delete the value nodes here.
|
||||
delete px;
|
||||
uprv_free(px);
|
||||
};
|
||||
U_CDECL_END
|
||||
|
||||
@ -685,7 +685,7 @@ void RBBIRuleScanner::findSetFor(const UnicodeString &s, RBBINode *node, Unicode
|
||||
//
|
||||
// Add the new set to the set hash table.
|
||||
//
|
||||
el = new RBBISetTableEl;
|
||||
el = (RBBISetTableEl *)uprv_malloc(sizeof(RBBISetTableEl));
|
||||
UnicodeString *tkey = new UnicodeString(s);
|
||||
if (tkey == NULL || el == NULL || setToAdopt == NULL) {
|
||||
error(U_MEMORY_ALLOCATION_ERROR);
|
||||
|
@ -459,9 +459,12 @@ void RBBISetBuilder::printSets() {
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//
|
||||
// RangeDesriptor copy constructor
|
||||
// RangeDescriptor copy constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
const char RangeDescriptor::fgClassID=0;
|
||||
|
||||
RangeDescriptor::RangeDescriptor(const RangeDescriptor &other, UErrorCode &status) {
|
||||
int i;
|
||||
|
||||
|
@ -33,7 +33,7 @@ U_NAMESPACE_BEGIN
|
||||
// All of them are strung together in a linked list, which is kept in order
|
||||
// (by character)
|
||||
//
|
||||
struct RangeDescriptor {
|
||||
struct RangeDescriptor : public UObject {
|
||||
UChar32 fStartChar; // Start of range, unicode 32 bit value.
|
||||
UChar32 fEndChar; // End of range, unicode 32 bit value.
|
||||
int32_t fNum; // runtime-mapped input value for this range.
|
||||
@ -49,6 +49,27 @@ struct RangeDescriptor {
|
||||
// where appearing in the second (higher) part.
|
||||
void setDictionaryFlag(); // Check whether this range appears as part of
|
||||
// the Unicode set named "dictionary"
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @draft ICU 2.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @draft ICU 2.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ UnicodeString::caseMap(BreakIterator *titleIter,
|
||||
oldArray, oldLength,
|
||||
&errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
delete [] bufferToDelete;
|
||||
uprv_free(bufferToDelete);
|
||||
setToBogus();
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user