ICU-1953 Test for NULL after each uprv_malloc() or new
X-SVN-Rev: 8980
This commit is contained in:
parent
89dd133d16
commit
1e188eca35
@ -61,9 +61,19 @@ BreakIterator::createWordInstance(const Locale& key, UErrorCode& status)
|
||||
if(!uprv_strcmp(filename, "word_th")) {
|
||||
filename = "thaidict.brk";
|
||||
result = new DictionaryBasedBreakIterator(file, filename, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = new RuleBasedBreakIterator(file, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,9 +105,19 @@ BreakIterator::createLineInstance(const Locale& key, UErrorCode& status)
|
||||
if (!uprv_strcmp(key.getLanguage(), "th")) {
|
||||
filename = "thaidict.brk";
|
||||
result = new DictionaryBasedBreakIterator(file, filename, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = new RuleBasedBreakIterator(file, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +142,11 @@ BreakIterator::createCharacterInstance(const Locale& key, UErrorCode& status)
|
||||
|
||||
if (!U_FAILURE(status)) {
|
||||
result = new RuleBasedBreakIterator(file, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -145,6 +170,11 @@ BreakIterator::createSentenceInstance(const Locale& key, UErrorCode& status)
|
||||
|
||||
if (!U_FAILURE(status)) {
|
||||
result = new RuleBasedBreakIterator(file, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -168,6 +198,11 @@ BreakIterator::createTitleInstance(const Locale& key, UErrorCode& status)
|
||||
|
||||
if (!U_FAILURE(status)) {
|
||||
result = new RuleBasedBreakIterator(file, status);
|
||||
//test for NULL
|
||||
if(result == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -39,6 +39,12 @@ DictionaryBasedBreakIterator::DictionaryBasedBreakIterator(UDataMemory* rbbiData
|
||||
{
|
||||
init();
|
||||
fTables = new DictionaryBasedBreakIteratorTables(dictionaryFilename, status);
|
||||
//test for NULL
|
||||
if(fTables == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
fTables->removeReference();
|
||||
fTables = NULL;
|
||||
@ -561,6 +567,11 @@ DictionaryBasedBreakIterator::divideUpDictionaryRange(int32_t startPos, int32_t
|
||||
uprv_free(cachedBreakPositions);
|
||||
}
|
||||
cachedBreakPositions = (int32_t *)uprv_malloc((currentBreakPositions.size() + 1) * sizeof(int32_t));
|
||||
//Test for NULL
|
||||
if(cachedBreakPositions == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
numCachedBreakPositions = currentBreakPositions.size() + 1;
|
||||
cachedBreakPositions[0] = startPos;
|
||||
|
||||
|
@ -48,6 +48,11 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode
|
||||
{
|
||||
init();
|
||||
fData = new RBBIDataWrapper(data, status);
|
||||
//test for NULL
|
||||
if(fData == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@ -60,6 +65,11 @@ RuleBasedBreakIterator::RuleBasedBreakIterator(UDataMemory* udm, UErrorCode &sta
|
||||
{
|
||||
init();
|
||||
fData = new RBBIDataWrapper(udm, status);
|
||||
//test for NULL
|
||||
if(fData == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,20 @@ RBBIRuleBuilder::RBBIRuleBuilder(const UnicodeString &rules,
|
||||
fDebugEnv = getenv("U_RBBIDEBUG"); // TODO: make conditional on some compile time setting
|
||||
|
||||
fScanner = new RBBIRuleScanner(this);
|
||||
//test for NULL
|
||||
if(fScanner == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
fSetBuilder = new RBBISetBuilder(this);
|
||||
//test for NULL
|
||||
if(fSetBuilder == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(fScanner);
|
||||
return;
|
||||
}
|
||||
|
||||
fSetsListHead = NULL;
|
||||
fForwardTree = NULL;
|
||||
fReverseTree = NULL;
|
||||
@ -202,7 +215,19 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
||||
// Generate the DFA state transition table.
|
||||
//
|
||||
builder.fForwardTables = new RBBITableBuilder(&builder, &builder.fForwardTree);
|
||||
//test for NULL
|
||||
if(builder.fForwardTables == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
builder.fReverseTables = new RBBITableBuilder(&builder, &builder.fReverseTree);
|
||||
//test for NULL
|
||||
if(builder.fReverseTables == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(builder.fForwardTables);
|
||||
return NULL;
|
||||
}
|
||||
builder.fForwardTables->build();
|
||||
builder.fReverseTables->build();
|
||||
if (U_FAILURE(status)) {
|
||||
@ -228,6 +253,12 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
||||
// (Identical to creation from stored pre-compiled rules)
|
||||
//
|
||||
RuleBasedBreakIterator *This = new RuleBasedBreakIterator(data, status);
|
||||
//test for NULL
|
||||
if(This == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
delete This;
|
||||
This = NULL;
|
||||
|
@ -469,6 +469,12 @@ RangeDescriptor::RangeDescriptor(const RangeDescriptor &other, UErrorCode &statu
|
||||
this->fNum = other.fNum;
|
||||
this->fNext = NULL;
|
||||
this->fIncludesSets = new UVector(status);
|
||||
//test for NULL
|
||||
if (this->fIncludesSets == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<other.fIncludesSets->size(); i++) {
|
||||
this->fIncludesSets->addElement(other.fIncludesSets->elementAt(i), status);
|
||||
}
|
||||
@ -486,6 +492,12 @@ RangeDescriptor::RangeDescriptor(UErrorCode &status) {
|
||||
this->fNum = 0;
|
||||
this->fNext = NULL;
|
||||
this->fIncludesSets = new UVector(status);
|
||||
//test for NULL
|
||||
if(this->fIncludesSets == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -507,6 +519,12 @@ RangeDescriptor::~RangeDescriptor() {
|
||||
void RangeDescriptor::split(UChar32 where, UErrorCode &status) {
|
||||
assert(where>fStartChar && where<=fEndChar);
|
||||
RangeDescriptor *nr = new RangeDescriptor(*this, status);
|
||||
//test for NULL
|
||||
if(nr == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// RangeDescriptor copy constructor copies all fields.
|
||||
// Only need to update those that are different after the split.
|
||||
nr->fStartChar = where;
|
||||
|
@ -175,8 +175,10 @@ ucmp8_openAdopt(uint16_t *indexArray,
|
||||
int8_t *newValues,
|
||||
int32_t count)
|
||||
{
|
||||
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
|
||||
|
||||
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
|
||||
//test for NULL
|
||||
if(this_obj == NULL)
|
||||
return NULL;
|
||||
ucmp8_initAdopt(this_obj, indexArray, newValues, count);
|
||||
this_obj->fIAmOwned = FALSE;
|
||||
return this_obj;
|
||||
@ -187,11 +189,13 @@ ucmp8_openAlias(uint16_t *indexArray,
|
||||
int8_t *newValues,
|
||||
int32_t count)
|
||||
{
|
||||
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
|
||||
|
||||
ucmp8_initAlias(this_obj, indexArray, newValues, count);
|
||||
this_obj->fIAmOwned = FALSE;
|
||||
return this_obj;
|
||||
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
|
||||
//test for NULL
|
||||
if(this_obj == NULL)
|
||||
return NULL;
|
||||
ucmp8_initAlias(this_obj, indexArray, newValues, count);
|
||||
this_obj->fIAmOwned = FALSE;
|
||||
return this_obj;
|
||||
}
|
||||
|
||||
/*=======================================================*/
|
||||
|
@ -75,9 +75,13 @@ _HZOpen(UConverter *cnv, const char *name,const char *locale,uint32_t options, U
|
||||
((UConverterDataHZ*)cnv->extraInfo)->sourceIndex = 0;
|
||||
((UConverterDataHZ*)cnv->extraInfo)->isTargetUCharDBCS = FALSE;
|
||||
}
|
||||
|
||||
|
||||
//test for NULL
|
||||
else {
|
||||
*errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_HZClose(UConverter *cnv){
|
||||
if((cnv->extraInfo != NULL) && !cnv->isCopyLocal){
|
||||
|
@ -207,6 +207,12 @@ UnicodeSet::UnicodeSet(const UnicodeString& pattern,
|
||||
buffer(0)
|
||||
{
|
||||
list = (UChar32*) uprv_malloc(sizeof(UChar32) * capacity);
|
||||
//test for NULL
|
||||
if(list == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
allocateStrings();
|
||||
applyPattern(pattern, status);
|
||||
_dbgct(this);
|
||||
@ -220,6 +226,11 @@ UnicodeSet::UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
|
||||
buffer(0)
|
||||
{
|
||||
list = (UChar32*) uprv_malloc(sizeof(UChar32) * capacity);
|
||||
//test for NULL
|
||||
if(list == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
allocateStrings();
|
||||
applyPattern(pattern, pos, &symbols, status);
|
||||
_dbgct(this);
|
||||
@ -232,6 +243,11 @@ UnicodeSet::UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
|
||||
buffer(0)
|
||||
{
|
||||
list = (UChar32*) uprv_malloc(sizeof(UChar32) * capacity);
|
||||
//test for NULL
|
||||
if(list == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
allocateStrings();
|
||||
applyPattern(pattern, pos, NULL, status);
|
||||
_dbgct(this);
|
||||
@ -257,6 +273,11 @@ UnicodeSet::UnicodeSet(int8_t category, UErrorCode& status) :
|
||||
pattern.insert(0, OPEN);
|
||||
pattern.append(CLOSE);
|
||||
list = (UChar32*) uprv_malloc(sizeof(UChar32) * capacity);
|
||||
//test for NULL
|
||||
if(list == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
allocateStrings();
|
||||
applyPattern(pattern, status);
|
||||
}
|
||||
|
@ -516,6 +516,11 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
||||
char *chAlias = NULL, *path = NULL, *locale = NULL, *keyPath = NULL;
|
||||
int32_t pathLen = 0, localeLen = 0, keyPathLen = 0;
|
||||
chAlias = (char *)uprv_malloc((len+1)*sizeof(char));
|
||||
//test for NULL
|
||||
if(chAlias == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
u_UCharsToChars(alias, chAlias, len);
|
||||
chAlias[len] = 0;
|
||||
|
||||
@ -615,6 +620,11 @@ static UResourceBundle *init_resb_result(const ResourceData *rdata, Resource r,
|
||||
}
|
||||
if(resB == NULL) {
|
||||
resB = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle));
|
||||
//test for NULL
|
||||
if (resB == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
ures_setIsStackObject(resB, FALSE);
|
||||
resB->fResPath = NULL;
|
||||
} else {
|
||||
@ -667,6 +677,11 @@ UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *origin
|
||||
if(r == NULL) {
|
||||
isStackObject = FALSE;
|
||||
r = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle));
|
||||
//test for NULL
|
||||
if (r == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
isStackObject = ures_isStackObject(r);
|
||||
if(U_FAILURE(*status)) {
|
||||
@ -675,6 +690,11 @@ UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *origin
|
||||
ures_close(r);
|
||||
if(isStackObject == FALSE) {
|
||||
r = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle));
|
||||
//test for NULL
|
||||
if (r == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
uprv_memcpy(r, original, sizeof(UResourceBundle));
|
||||
@ -1027,6 +1047,11 @@ ures_findResource(const char* path, UResourceBundle *fillIn, UErrorCode *status)
|
||||
return result;
|
||||
}
|
||||
pathToResource = (char *)uprv_malloc((uprv_strlen(path)+1)*sizeof(char));
|
||||
//test for NULL
|
||||
if(pathToResource == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return result;
|
||||
}
|
||||
uprv_strcpy(pathToResource, path);
|
||||
locale = pathToResource;
|
||||
if(*pathToResource == RES_PATH_SEPARATOR) { /* there is a path specification */
|
||||
@ -1453,6 +1478,11 @@ ures_openW(const wchar_t* myPath,
|
||||
UResourceBundle *r;
|
||||
size_t pathSize = (uprv_wcslen(myPath) + 1) * sizeof(int32_t);
|
||||
char *path = (char *)uprv_malloc(pathSize);
|
||||
//test for NULL
|
||||
if (path == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uprv_wcstombs(path, myPath, pathSize);
|
||||
|
||||
@ -1476,6 +1506,11 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_openU(const UChar* myPath,
|
||||
UResourceBundle *r;
|
||||
int32_t pathSize = u_strlen(myPath) + 1;
|
||||
char *path = (char *)uprv_malloc(pathSize);
|
||||
//test for NULL
|
||||
if(path == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_UCharsToChars(myPath, path, pathSize);
|
||||
|
||||
|
@ -37,6 +37,12 @@ uset_openPattern(const UChar* pattern, int32_t patternLength,
|
||||
UErrorCode* ec) {
|
||||
UnicodeString pat(patternLength==-1, pattern, patternLength);
|
||||
UnicodeSet* set = new UnicodeSet(pat, *ec);
|
||||
//test for NULL
|
||||
if(set == NULL) {
|
||||
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(*ec)) {
|
||||
delete set;
|
||||
set = NULL;
|
||||
|
@ -501,6 +501,12 @@ removeLamAlefSpaces(UChar *dest, int32_t sourceLength,
|
||||
switch(options&U_SHAPE_LENGTH_MASK) {
|
||||
case U_SHAPE_LENGTH_GROW_SHRINK :
|
||||
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
i = j = 0;
|
||||
@ -538,6 +544,13 @@ removeLamAlefSpaces(UChar *dest, int32_t sourceLength,
|
||||
|
||||
case U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING :
|
||||
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
i = j = sourceLength;
|
||||
@ -560,6 +573,13 @@ removeLamAlefSpaces(UChar *dest, int32_t sourceLength,
|
||||
|
||||
case U_SHAPE_LENGTH_FIXED_SPACES_AT_END :
|
||||
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
i = j = 0;
|
||||
@ -622,6 +642,13 @@ expandLamAlef(UChar *dest, int32_t sourceLength,
|
||||
case U_SHAPE_LENGTH_GROW_SHRINK :
|
||||
destSize = calculateSize(dest,sourceLength,destSize,options);
|
||||
tempbuffer = (UChar *)uprv_malloc((destSize+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (destSize+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
i = j = 0;
|
||||
@ -657,6 +684,13 @@ expandLamAlef(UChar *dest, int32_t sourceLength,
|
||||
|
||||
case U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING :
|
||||
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
i = 0;
|
||||
@ -691,6 +725,13 @@ expandLamAlef(UChar *dest, int32_t sourceLength,
|
||||
* the spaces with the LamAlefs as they appear in the visual buffer from right to left
|
||||
*/
|
||||
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
|
||||
|
||||
while(dest[inpsize-1] == 0x0020) {
|
||||
@ -983,6 +1024,12 @@ u_shapeArabic(const UChar *source, int32_t sourceLength,
|
||||
tempbuffer=buffer;
|
||||
} else {
|
||||
tempbuffer = (UChar *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
|
||||
|
||||
//Test for NULL
|
||||
if(tempbuffer == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
uprv_memcpy(tempbuffer, source, sourceLength*U_SIZEOF_UCHAR);
|
||||
if(sourceLength<outputSize) {
|
||||
|
@ -186,6 +186,11 @@ Calendar::createInstance(UErrorCode& success)
|
||||
if (U_FAILURE(success)) return 0;
|
||||
// right now, createInstance will always return an instance of GregorianCalendar
|
||||
Calendar* c = new GregorianCalendar(success);
|
||||
//test for NULL
|
||||
if (c == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(success)) { delete c; c = 0; }
|
||||
return c;
|
||||
}
|
||||
@ -198,6 +203,11 @@ Calendar::createInstance(const TimeZone& zone, UErrorCode& success)
|
||||
if (U_FAILURE(success)) return 0;
|
||||
// since the Locale isn't specified, use the default locale
|
||||
Calendar* c = new GregorianCalendar(zone, Locale::getDefault(), success);
|
||||
//test for NULL
|
||||
if (c == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(success)) { delete c; c = 0; }
|
||||
return c;
|
||||
}
|
||||
@ -210,6 +220,11 @@ Calendar::createInstance(const Locale& aLocale, UErrorCode& success)
|
||||
if (U_FAILURE(success)) return 0;
|
||||
// since the TimeZone isn't specfied, use the default time zone
|
||||
Calendar* c = new GregorianCalendar(TimeZone::createDefault(), aLocale, success);
|
||||
//test for NULL
|
||||
if (c == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(success)) { delete c; c = 0; }
|
||||
return c;
|
||||
}
|
||||
@ -241,6 +256,11 @@ Calendar::createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode
|
||||
{
|
||||
if (U_FAILURE(success)) return 0;
|
||||
Calendar* c = new GregorianCalendar(zone, aLocale, success);
|
||||
//test for NULL
|
||||
if (c == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(success)) { delete c; c = 0; }
|
||||
return c;
|
||||
}
|
||||
@ -582,10 +602,10 @@ void
|
||||
Calendar::adoptTimeZone(TimeZone* zone)
|
||||
{
|
||||
// Do nothing if passed-in zone is NULL
|
||||
if (zone == NULL) return;
|
||||
if (zone == 0) return;
|
||||
|
||||
// fZone should always be non-null
|
||||
if (fZone != NULL) delete fZone;
|
||||
if (fZone != 0) delete fZone;
|
||||
fZone = zone;
|
||||
|
||||
// if the zone changes, we need to recompute the time fields
|
||||
@ -767,7 +787,7 @@ Calendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status)
|
||||
fFirstDayOfWeek = Calendar::SUNDAY;
|
||||
fMinimalDaysInFirstWeek = 1;
|
||||
|
||||
UResourceBundle *resource = ures_open(NULL, desiredLocale.getName(), &status);
|
||||
UResourceBundle *resource = ures_open(0, desiredLocale.getName(), &status);
|
||||
|
||||
// If the resource data doesn't seem to be present at all, then use last-resort
|
||||
// hard-coded data.
|
||||
@ -779,7 +799,7 @@ Calendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status)
|
||||
}
|
||||
|
||||
//dateTimeElements = resource.getStringArray(kDateTimeElements, count, status);
|
||||
UResourceBundle *dateTimeElements = ures_getByKey(resource, kDateTimeElements, NULL, &status);
|
||||
UResourceBundle *dateTimeElements = ures_getByKey(resource, kDateTimeElements, 0, &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
int32_t arrLen;
|
||||
const int32_t *dateTimeElementsArr = ures_getIntVector(dateTimeElements, &arrLen, &status);
|
||||
|
@ -181,18 +181,49 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
||||
if (newSource.length() == 0) {
|
||||
pieces_length = 1;
|
||||
pieces = new UnicodeString*[1];
|
||||
//test for NULL
|
||||
if (pieces == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
current_length = 1;
|
||||
current = (int32_t*)uprv_malloc(1 * sizeof(int32_t));
|
||||
//test for NULL
|
||||
if (current == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete pieces;
|
||||
return;
|
||||
}
|
||||
current[0] = 0;
|
||||
pieces[0] = new UnicodeString[1];
|
||||
//test for NULL
|
||||
if (pieces[0] == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete pieces;
|
||||
delete current;
|
||||
return;
|
||||
}
|
||||
pieces[0][0] = UnicodeString("");
|
||||
pieces_lengths = (int32_t*)uprv_malloc(1 * sizeof(int32_t));
|
||||
//test for NULL
|
||||
if (pieces_lengths == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete[] pieces;
|
||||
delete current;
|
||||
return;
|
||||
}
|
||||
pieces_lengths[0] = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UnicodeString *list = new UnicodeString[source.length()];
|
||||
//test for NULL
|
||||
if (list == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t list_length = 0;
|
||||
UChar32 cp = 0;
|
||||
int32_t start = 0;
|
||||
@ -217,11 +248,32 @@ void CanonicalIterator::setSource(const UnicodeString &newSource, UErrorCode &st
|
||||
|
||||
// allocate the arrays, and find the strings that are CE to each segment
|
||||
pieces = new UnicodeString*[list_length];
|
||||
//test for NULL
|
||||
if (pieces == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete[] list;
|
||||
return;
|
||||
}
|
||||
pieces_length = list_length;
|
||||
pieces_lengths = (int32_t*)uprv_malloc(list_length * sizeof(int32_t));
|
||||
//test for NULL
|
||||
if (pieces_lengths == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete[] list;
|
||||
delete[] pieces;
|
||||
return;
|
||||
}
|
||||
|
||||
current_length = list_length;
|
||||
current = (int32_t*)uprv_malloc(list_length * sizeof(int32_t));
|
||||
//test for NULL
|
||||
if (current == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete[] list;
|
||||
delete[] pieces;
|
||||
delete pieces_lengths;
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < current_length; i++) {
|
||||
current[i] = 0;
|
||||
}
|
||||
@ -253,6 +305,11 @@ void CanonicalIterator::permute(UnicodeString &source, UBool skipZeros, Hashtabl
|
||||
// we check for length < 2 to keep from counting code points all the time
|
||||
if (source.length() <= 2 && source.countChar32() <= 1) {
|
||||
UnicodeString *toPut = new UnicodeString(source);
|
||||
//test for NULL
|
||||
if (toPut == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
result->put(source, toPut, status);
|
||||
return;
|
||||
}
|
||||
@ -260,6 +317,11 @@ void CanonicalIterator::permute(UnicodeString &source, UBool skipZeros, Hashtabl
|
||||
// otherwise iterate through the string, and recursively permute all the other characters
|
||||
UChar32 cp;
|
||||
Hashtable *subpermute = new Hashtable(FALSE, status);
|
||||
//test for NULL
|
||||
if (subpermute == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
subpermute->setValueDeleter(uhash_deleteUnicodeString);
|
||||
}
|
||||
@ -291,6 +353,12 @@ void CanonicalIterator::permute(UnicodeString &source, UBool skipZeros, Hashtabl
|
||||
while (ne != NULL) {
|
||||
UnicodeString *permRes = (UnicodeString *)(ne->value.pointer);
|
||||
UnicodeString *chStr = new UnicodeString(cp);
|
||||
//test for NULL
|
||||
if (chStr == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete subpermute;
|
||||
return;
|
||||
}
|
||||
chStr->append(*permRes); //*((UnicodeString *)(ne->value.pointer));
|
||||
//if (PROGRESS) printf(" Piece: %s\n", UToS(*chStr));
|
||||
result->put(*chStr, chStr, status);
|
||||
@ -308,6 +376,11 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
||||
//private String[] getEquivalents(String segment)
|
||||
|
||||
Hashtable *result = new Hashtable(FALSE, status);
|
||||
//test for NULL
|
||||
if (result == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
result->setValueDeleter(uhash_deleteUnicodeString);
|
||||
}
|
||||
@ -321,6 +394,13 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
||||
// TODO: optimize by not permuting any class zero.
|
||||
|
||||
Hashtable *permutations = new Hashtable(FALSE, status);
|
||||
//test for NULL
|
||||
if (permutations == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete result;
|
||||
delete basic;
|
||||
return 0;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
permutations->setValueDeleter(uhash_deleteUnicodeString);
|
||||
}
|
||||
@ -365,6 +445,14 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
|
||||
// convert into a String[] to clean up storage
|
||||
//String[] finalResult = new String[result.size()];
|
||||
UnicodeString *finalResult = new UnicodeString[result->count()];
|
||||
//test for NULL
|
||||
if (finalResult == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete result;
|
||||
delete permutations;
|
||||
delete basic;
|
||||
return 0;
|
||||
}
|
||||
//result.toArray(finalResult);
|
||||
result_len = 0;
|
||||
el = -1;
|
||||
@ -386,6 +474,11 @@ Hashtable *CanonicalIterator::getEquivalents2(const UChar *segment, int32_t segL
|
||||
//Hashtable *CanonicalIterator::getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status) {
|
||||
|
||||
Hashtable *result = new Hashtable(FALSE, status);
|
||||
//test for NULL
|
||||
if (result == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
result->setValueDeleter(uhash_deleteUnicodeString);
|
||||
}
|
||||
@ -423,6 +516,13 @@ Hashtable *CanonicalIterator::getEquivalents2(const UChar *segment, int32_t segL
|
||||
while (ne != NULL) {
|
||||
UnicodeString item = *((UnicodeString *)(ne->value.pointer));
|
||||
UnicodeString *toAdd = new UnicodeString(prefix);
|
||||
//test for NULL
|
||||
if (toAdd == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete result;
|
||||
delete remainder;
|
||||
return 0;
|
||||
}
|
||||
*toAdd += item;
|
||||
result->put(*toAdd, toAdd, status);
|
||||
|
||||
@ -514,6 +614,11 @@ Hashtable *CanonicalIterator::extract(UChar32 comp, const UChar *segment, int32_
|
||||
|
||||
if (bufLen == 0) {
|
||||
Hashtable *result = new Hashtable(FALSE, status);
|
||||
//test for NULL
|
||||
if (result == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
result->setValueDeleter(uhash_deleteUnicodeString);
|
||||
result->put("", new UnicodeString(""), status);
|
||||
return result; // succeed, but no remainder
|
||||
|
@ -270,14 +270,33 @@ ChoiceFormat::applyPattern(const UnicodeString& pattern,
|
||||
|
||||
// Allocate the required storage.
|
||||
double *newLimits = (double*) uprv_malloc( sizeof(double) * count);
|
||||
//test for NULL
|
||||
if (newLimits == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
UBool *newClosures = (UBool*) uprv_malloc( sizeof(UBool) * count);
|
||||
//test for NULL
|
||||
if (newClosures == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete newLimits;
|
||||
return;
|
||||
}
|
||||
UnicodeString *newFormats = new UnicodeString[count];
|
||||
//test for NULL
|
||||
if (newFormats == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete newLimits;
|
||||
delete newClosures;
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform the second pass
|
||||
int32_t k = 0; // index into newXxx[] arrays
|
||||
UnicodeString buf; // scratch buffer
|
||||
UBool inQuote = FALSE;
|
||||
UBool inNumber = TRUE; // TRUE before < or #, FALSE after
|
||||
|
||||
for (i=0; i<pattern.length(); ++i) {
|
||||
UChar c = pattern[i];
|
||||
if (c == SINGLE_QUOTE) {
|
||||
|
@ -171,10 +171,20 @@ void CollationElementIterator::setText(const UnicodeString& source,
|
||||
m_data_->isWritable = TRUE;
|
||||
if (length > 0) {
|
||||
string = (UChar *)uprv_malloc(U_SIZEOF_UCHAR * length);
|
||||
//Test for NULL
|
||||
if (string == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
u_memcpy(string, source.getBuffer(), length);
|
||||
}
|
||||
else {
|
||||
string = (UChar *)uprv_malloc(U_SIZEOF_UCHAR);
|
||||
//Test for NULL
|
||||
if (string == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
*string = 0;
|
||||
}
|
||||
init_collIterate(m_data_->iteratordata_.coll, string, length,
|
||||
@ -195,10 +205,20 @@ void CollationElementIterator::setText(CharacterIterator& source,
|
||||
|
||||
if (length == 0) {
|
||||
buffer = (UChar *)uprv_malloc(U_SIZEOF_UCHAR);
|
||||
//Test for NULL
|
||||
if (buffer == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
*buffer = 0;
|
||||
}
|
||||
else {
|
||||
buffer = (UChar *)uprv_malloc(U_SIZEOF_UCHAR * length);
|
||||
//Test for NULL
|
||||
if (buffer == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
Using this constructor will prevent buffer from being removed when
|
||||
string gets removed
|
||||
@ -249,6 +269,11 @@ CollationElementIterator::CollationElementIterator(
|
||||
|
||||
if (length > 0) {
|
||||
string = (UChar *)uprv_malloc(U_SIZEOF_UCHAR * length);
|
||||
//Test for NULL
|
||||
if (string == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
Using this constructor will prevent buffer from being removed when
|
||||
string gets removed
|
||||
@ -257,6 +282,11 @@ CollationElementIterator::CollationElementIterator(
|
||||
}
|
||||
else {
|
||||
string = (UChar *)uprv_malloc(U_SIZEOF_UCHAR);
|
||||
//test for NULL
|
||||
if (string == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
*string = 0;
|
||||
}
|
||||
m_data_ = ucol_openElements(order->ucollator, string, length, &status);
|
||||
@ -299,6 +329,11 @@ CollationElementIterator::CollationElementIterator(
|
||||
UChar *buffer;
|
||||
if (length > 0) {
|
||||
buffer = (UChar *)uprv_malloc(U_SIZEOF_UCHAR * length);
|
||||
//test for NULL
|
||||
if (buffer == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
Using this constructor will prevent buffer from being removed when
|
||||
string gets removed
|
||||
@ -310,6 +345,11 @@ CollationElementIterator::CollationElementIterator(
|
||||
}
|
||||
else {
|
||||
buffer = (UChar *)uprv_malloc(U_SIZEOF_UCHAR);
|
||||
//test for NULL
|
||||
if (buffer == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
*buffer = 0;
|
||||
}
|
||||
m_data_ = ucol_openElements(order->ucollator, buffer, length, &status);
|
||||
|
@ -81,10 +81,15 @@ Collator* Collator::createInstance(const Locale& desiredLocale,
|
||||
|
||||
RuleBasedCollator* collation = new RuleBasedCollator(desiredLocale,
|
||||
status);
|
||||
//test for NULL
|
||||
if (collation == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
delete collation;
|
||||
collation = NULL;
|
||||
collation = 0;
|
||||
}
|
||||
return collation;
|
||||
}
|
||||
@ -97,12 +102,18 @@ Collator::createInstance(const Locale &loc,
|
||||
UVersionInfo info;
|
||||
|
||||
collator=new RuleBasedCollator(loc, status);
|
||||
//test for NULL
|
||||
if (collator == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(U_SUCCESS(status)) {
|
||||
collator->getVersion(info);
|
||||
if(0!=uprv_memcmp(version, info, sizeof(UVersionInfo))) {
|
||||
delete collator;
|
||||
status=U_MISSING_RESOURCE_ERROR;
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return collator;
|
||||
|
@ -183,6 +183,11 @@ void CompoundTransliterator::init(UVector& list,
|
||||
if (U_SUCCESS(status)) {
|
||||
count = list.size();
|
||||
trans = new Transliterator*[count];
|
||||
//test for NULL
|
||||
if (trans == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (U_FAILURE(status) || trans == 0) {
|
||||
@ -375,18 +380,18 @@ void CompoundTransliterator::handleGetSourceSet(UnicodeSet& result) const {
|
||||
UnicodeSet set;
|
||||
result.clear();
|
||||
for (int32_t i=0; i<count; ++i) {
|
||||
result.addAll(trans[i]->getSourceSet(set));
|
||||
// Take the example of Hiragana-Latin. This is really
|
||||
// Hiragana-Katakana; Katakana-Latin. The source set of
|
||||
// these two is roughly [:Hiragana:] and [:Katakana:].
|
||||
// But the source set for the entire transliterator is
|
||||
// actually [:Hiragana:] ONLY -- that is, the first
|
||||
// non-empty source set.
|
||||
result.addAll(trans[i]->getSourceSet(set));
|
||||
// Take the example of Hiragana-Latin. This is really
|
||||
// Hiragana-Katakana; Katakana-Latin. The source set of
|
||||
// these two is roughly [:Hiragana:] and [:Katakana:].
|
||||
// But the source set for the entire transliterator is
|
||||
// actually [:Hiragana:] ONLY -- that is, the first
|
||||
// non-empty source set.
|
||||
|
||||
// This is a heuristic, and not 100% reliable.
|
||||
if (!result.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
// This is a heuristic, and not 100% reliable.
|
||||
if (!result.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,8 +402,8 @@ UnicodeSet& CompoundTransliterator::getTargetSet(UnicodeSet& result) const {
|
||||
UnicodeSet set;
|
||||
result.clear();
|
||||
for (int32_t i=0; i<count; ++i) {
|
||||
// This is a heuristic, and not 100% reliable.
|
||||
result.addAll(trans[i]->getTargetSet(set));
|
||||
// This is a heuristic, and not 100% reliable.
|
||||
result.addAll(trans[i]->getTargetSet(set));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -125,6 +125,11 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
|
||||
ResourceBundle numberElementsRes = resource.get(fgNumberElements, status);
|
||||
int32_t numberElementsLength = numberElementsRes.getSize();
|
||||
UnicodeString* numberElements = new UnicodeString[numberElementsLength];
|
||||
//test for NULL
|
||||
if (numberElements == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for(i = 0; i<numberElementsLength; i++) {
|
||||
numberElements[i] = numberElementsRes.getStringEx(i, status);
|
||||
}
|
||||
@ -133,6 +138,12 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
|
||||
ResourceBundle currencyElementsRes = resource.get(fgCurrencyElements, status);
|
||||
int32_t currencyElementsLength = currencyElementsRes.getSize();
|
||||
UnicodeString* currencyElements = new UnicodeString[currencyElementsLength];
|
||||
//test for NULL
|
||||
if (currencyElements == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete[] numberElements;
|
||||
return;
|
||||
}
|
||||
for(i = 0; i<currencyElementsLength; i++) {
|
||||
currencyElements[i] = currencyElementsRes.getStringEx(i, status);
|
||||
}
|
||||
|
@ -216,6 +216,11 @@ DecimalFormat::construct(UErrorCode& status,
|
||||
if (fSymbols == NULL)
|
||||
{
|
||||
fSymbols = new DecimalFormatSymbols(Locale::getDefault(), status);
|
||||
//test for NULL
|
||||
if (fSymbols == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString str;
|
||||
@ -2767,7 +2772,18 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
|
||||
delete fNegPrefixPattern;
|
||||
delete fNegSuffixPattern;
|
||||
fPosPrefixPattern = new UnicodeString(prefix);
|
||||
//test for NULL
|
||||
if (fPosPrefixPattern == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fPosSuffixPattern = new UnicodeString(suffix);
|
||||
//test for NULL
|
||||
if (fPosSuffixPattern == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete fPosPrefixPattern;
|
||||
return;
|
||||
}
|
||||
fNegPrefixPattern = 0;
|
||||
fNegSuffixPattern = 0;
|
||||
|
||||
@ -2816,6 +2832,13 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
|
||||
*fRoundingIncrement = roundingInc;
|
||||
} else {
|
||||
fRoundingIncrement = new DigitList(roundingInc);
|
||||
//test for NULL
|
||||
if (fRoundingIncrement == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete fPosPrefixPattern;
|
||||
delete fPosSuffixPattern;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fRoundingDouble = fRoundingIncrement->getDouble();
|
||||
fRoundingMode = kRoundHalfEven;
|
||||
@ -2824,7 +2847,18 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
|
||||
}
|
||||
} else {
|
||||
fNegPrefixPattern = new UnicodeString(prefix);
|
||||
//test for NULL
|
||||
if (fNegPrefixPattern == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fNegSuffixPattern = new UnicodeString(suffix);
|
||||
//test for NULL
|
||||
if (fNegSuffixPattern == 0) {
|
||||
delete fNegPrefixPattern;
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2837,11 +2871,22 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
|
||||
fPosPrefixPattern->remove();
|
||||
} else {
|
||||
fPosPrefixPattern = new UnicodeString();
|
||||
//test for NULL
|
||||
if (fPosPrefixPattern == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fPosSuffixPattern != NULL) {
|
||||
fPosSuffixPattern->remove();
|
||||
} else {
|
||||
fPosSuffixPattern = new UnicodeString();
|
||||
//test for NULL
|
||||
if (fPosSuffixPattern == 0) {
|
||||
delete fPosPrefixPattern;
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setMinimumIntegerDigits(0);
|
||||
@ -2869,6 +2914,11 @@ DecimalFormat::applyPattern(const UnicodeString& pattern,
|
||||
_copy_us_ptr(&fNegSuffixPattern, fPosSuffixPattern);
|
||||
if (fNegPrefixPattern == NULL) {
|
||||
fNegPrefixPattern = new UnicodeString();
|
||||
//test for NULL
|
||||
if (fNegPrefixPattern == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fNegPrefixPattern->remove();
|
||||
}
|
||||
|
@ -542,6 +542,11 @@ DateFormatSymbols::initializeData(const Locale& locale, UErrorCode& status, UBoo
|
||||
initField(&fAmPms, fAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
|
||||
|
||||
fZoneStrings = new UnicodeString*[1];
|
||||
//test for NULL
|
||||
if (fZoneStrings == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fZoneStringsRowCount = 1;
|
||||
initField(fZoneStrings, fZoneStringsColCount, (const UChar *)gLastResortZoneStrings, kZoneNum, kZoneLen, status);
|
||||
fLocalPatternChars = gPatternChars;
|
||||
@ -573,8 +578,18 @@ DateFormatSymbols::initializeData(const Locale& locale, UErrorCode& status, UBoo
|
||||
/* TODO: Fix the case where the zoneStrings is not a perfect square array of information. */
|
||||
fZoneStringsColCount = zoneRow.getSize();
|
||||
fZoneStrings = new UnicodeString * [fZoneStringsRowCount];
|
||||
//test for NULL
|
||||
if (fZoneStrings == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for(i = 0; i<fZoneStringsRowCount; i++) {
|
||||
*(fZoneStrings+i) = new UnicodeString[fZoneStringsColCount];
|
||||
//test for NULL
|
||||
if ((*(fZoneStrings+i)) == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
zoneRow = zoneArray.get(i, status);
|
||||
for(int32_t j = 0; j<fZoneStringsColCount; j++) {
|
||||
fZoneStrings[i][j] = zoneRow.getStringEx(j, status);
|
||||
@ -585,6 +600,11 @@ DateFormatSymbols::initializeData(const Locale& locale, UErrorCode& status, UBoo
|
||||
ResourceBundle weekdaysData = resource.get(fgDayNamesTag, status);
|
||||
fWeekdaysCount = weekdaysData.getSize();
|
||||
fWeekdays = new UnicodeString[fWeekdaysCount+1];
|
||||
//test for NULL
|
||||
if (fWeekdays == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fWeekdays[0] = UnicodeString();
|
||||
for(i = 0; i<fWeekdaysCount; i++) {
|
||||
fWeekdays[i+1] = weekdaysData.getStringEx(i, status);
|
||||
@ -593,6 +613,11 @@ DateFormatSymbols::initializeData(const Locale& locale, UErrorCode& status, UBoo
|
||||
ResourceBundle lsweekdaysData = resource.get(fgDayAbbreviationsTag, status);
|
||||
fShortWeekdaysCount = lsweekdaysData.getSize();
|
||||
fShortWeekdays = new UnicodeString[fShortWeekdaysCount+1];
|
||||
//test for NULL
|
||||
if (fShortWeekdays == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fShortWeekdays[0] = UnicodeString();
|
||||
for(i = 0; i<fShortWeekdaysCount; i++) {
|
||||
fShortWeekdays[i+1] = lsweekdaysData.getStringEx(i, status);
|
||||
|
@ -340,6 +340,11 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status)
|
||||
// Normalize the year so BC values are represented as 0 and negative
|
||||
// values.
|
||||
GregorianCalendar *cal = new GregorianCalendar(getTimeZone(), status);
|
||||
//test for NULL
|
||||
if (cal == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
if(U_FAILURE(status))
|
||||
return;
|
||||
cal->setTime(date, status);
|
||||
|
@ -118,7 +118,18 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
|
||||
fArgumentNumbers(NULL)
|
||||
{
|
||||
fOffsets = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fOffsets == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fArgumentNumbers = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fArgumentNumbers == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete fOffsets;
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < fCount; i++) {
|
||||
fFormats[i] = NULL; // Format instances
|
||||
fOffsets[i] = 0; // Starting offset
|
||||
@ -136,7 +147,18 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
|
||||
fArgumentNumbers(NULL)
|
||||
{
|
||||
fOffsets = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fOffsets == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fArgumentNumbers = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fArgumentNumbers == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete fOffsets;
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < fCount; i++) {
|
||||
fFormats[i] = NULL; // Format instances
|
||||
fOffsets[i] = 0; // Starting offset
|
||||
@ -155,7 +177,18 @@ MessageFormat::MessageFormat(const UnicodeString& pattern,
|
||||
fArgumentNumbers(NULL)
|
||||
{
|
||||
fOffsets = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fOffsets == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
fArgumentNumbers = (int32_t*) uprv_malloc( sizeof(int32_t) * fCount );
|
||||
//test for NULL
|
||||
if (fArgumentNumbers == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete fOffsets;
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < fCount; i++) {
|
||||
fFormats[i] = NULL; // Format instances
|
||||
fOffsets[i] = 0; // Starting offset
|
||||
@ -746,6 +779,11 @@ MessageFormat::format( const UnicodeString& pattern,
|
||||
{
|
||||
// {sfb} why does this use a local when so many other places use a static?
|
||||
MessageFormat *temp = new MessageFormat(pattern, success);
|
||||
//test for NULL
|
||||
if (temp == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
return result;
|
||||
}
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
FieldPosition ignore(0);
|
||||
@ -862,6 +900,11 @@ MessageFormat::format(const Formattable* arguments,
|
||||
if (tryRecursion && arg.indexOf(LEFT_CURLY_BRACE) >= 0) {
|
||||
MessageFormat *temp = NULL;
|
||||
temp = new MessageFormat(arg, fLocale, success);
|
||||
//test for NULL
|
||||
if (temp == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return result;
|
||||
}
|
||||
if (U_FAILURE(success))
|
||||
return result;
|
||||
temp->format(arguments, cnt, result, status, recursionProtection, success);
|
||||
@ -1279,6 +1322,12 @@ MessageFormat::makeFormat(/*int32_t position, */
|
||||
fFormatTypeList[argumentNumber] = Formattable::kDouble;
|
||||
|
||||
newFormat = new ChoiceFormat(segments[3], parseError, success);
|
||||
//test for NULL
|
||||
if (newFormat == 0) {
|
||||
success = U_MEMORY_ALLOCATION_ERROR;
|
||||
fMaxOffset = oldMaxOffset;
|
||||
return argumentNumber;
|
||||
}
|
||||
if(U_FAILURE(success)) {
|
||||
fMaxOffset = oldMaxOffset;
|
||||
return argumentNumber;
|
||||
|
@ -102,6 +102,11 @@ NFRule::makeRules(UnicodeString& description,
|
||||
// (this also strips the rule descriptor, if any, off the
|
||||
// descripton string)
|
||||
NFRule* rule1 = new NFRule(rbnf);
|
||||
//test for NULL
|
||||
if (rule1 == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
rule1->parseRuleDescriptor(description, status);
|
||||
|
||||
// check the description to see whether there's text enclosed
|
||||
@ -139,6 +144,11 @@ NFRule::makeRules(UnicodeString& description,
|
||||
// increment the original rule's base value ("rule1" actually
|
||||
// goes SECOND in the rule set's rule list)
|
||||
rule2 = new NFRule(rbnf);
|
||||
//test for NULL
|
||||
if (rule2 == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
if (rule1->baseValue >= 0) {
|
||||
rule2->baseValue = rule1->baseValue;
|
||||
if (!ruleSet->isFractionRuleSet()) {
|
||||
|
@ -169,6 +169,11 @@ NFSubstitution::NFSubstitution(int32_t _pos,
|
||||
// belonging to our formatter)
|
||||
else if (workingDescription.charAt(0) == gPound || workingDescription.charAt(0) ==gZero) {
|
||||
this->numberFormat = new DecimalFormat(workingDescription, *(formatter->getDecimalFormatSymbols()), status);
|
||||
//test for NULL
|
||||
if (this->numberFormat == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
// this->numberFormat->setDecimalFormatSymbols(formatter->getDecimalFormatSymbols());
|
||||
}
|
||||
// if the description is ">>>", this substitution bypasses the
|
||||
|
@ -130,9 +130,14 @@ RuleBasedNumberFormat::clone(void) const
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UParseError perror;
|
||||
result = new RuleBasedNumberFormat(rules, locale, perror, status);
|
||||
//test for NULL
|
||||
if (result == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete result;
|
||||
result = NULL;
|
||||
result = 0;
|
||||
} else {
|
||||
result->lenient = lenient;
|
||||
}
|
||||
@ -418,6 +423,11 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, UParseError& pErr, UErro
|
||||
// copy out the lenient-parse rules and delete them
|
||||
// from the description
|
||||
lenientParseRules = new UnicodeString();
|
||||
//test for NULL
|
||||
if (lenientParseRules == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
lenientParseRules->setTo(description, lpStart, lpEnd - lpStart);
|
||||
|
||||
description.remove(lp, lpEnd + 1 - lp);
|
||||
@ -436,6 +446,12 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, UParseError& pErr, UErro
|
||||
|
||||
// our rule list is an array of the appropriate size
|
||||
ruleSets = new NFRuleSet*[numRuleSets + 1];
|
||||
//test for NULL
|
||||
if (ruleSets == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= numRuleSets; ++i) {
|
||||
ruleSets[i] = NULL;
|
||||
}
|
||||
@ -448,6 +464,11 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, UParseError& pErr, UErro
|
||||
// because we have to know the names and locations of all the rule
|
||||
// sets before we can actually set everything up
|
||||
UnicodeString* ruleSetDescriptions = new UnicodeString[numRuleSets];
|
||||
//test for NULL
|
||||
if (ruleSetDescriptions == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
int curRuleSet = 0;
|
||||
@ -455,11 +476,21 @@ RuleBasedNumberFormat::init(const UnicodeString& rules, UParseError& pErr, UErro
|
||||
for (int32_t p = description.indexOf(gSemiPercent); p != -1; p = description.indexOf(gSemiPercent, start)) {
|
||||
ruleSetDescriptions[curRuleSet].setTo(description, start, p + 1 - start);
|
||||
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet, status);
|
||||
//test for NULL
|
||||
if (ruleSets[curRuleSet] == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
++curRuleSet;
|
||||
start = p + 1;
|
||||
}
|
||||
ruleSetDescriptions[curRuleSet].setTo(description, start, description.length() - start);
|
||||
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet, status);
|
||||
//test for NULL
|
||||
if (ruleSets[curRuleSet] == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// now we can take note of the formatter's default rule set, which
|
||||
|
@ -24,6 +24,11 @@ TransliterationRuleData::TransliterationRuleData(UErrorCode& status)
|
||||
return;
|
||||
}
|
||||
variableNames = new Hashtable(status);
|
||||
//test for NULL
|
||||
if (variableNames == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
if (U_SUCCESS(status)) {
|
||||
variableNames->setValueDeleter(uhash_deleteUnicodeString);
|
||||
}
|
||||
@ -52,6 +57,11 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
|
||||
variables = 0;
|
||||
if (other.variables != 0) {
|
||||
variables = new UnicodeFunctor*[variablesLength];
|
||||
//test for NULL
|
||||
if (variables == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for (int32_t i=0; i<variablesLength; ++i) {
|
||||
variables[i] = other.variables[i]->clone();
|
||||
}
|
||||
|
@ -112,12 +112,22 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
|
||||
if (anteContextLength > 0) {
|
||||
anteContext = new StringMatcher(pattern, 0, anteContextLength,
|
||||
FALSE, *data);
|
||||
//test for NULL
|
||||
if (anteContext == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
key = NULL;
|
||||
if (keyLength > 0) {
|
||||
key = new StringMatcher(pattern, anteContextLength, anteContextLength + keyLength,
|
||||
FALSE, *data);
|
||||
//test for NULL
|
||||
if (key == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t postContextLength = pattern.length() - keyLength - anteContextLength;
|
||||
@ -125,9 +135,19 @@ TransliterationRule::TransliterationRule(const UnicodeString& input,
|
||||
if (postContextLength > 0) {
|
||||
postContext = new StringMatcher(pattern, anteContextLength + keyLength, pattern.length(),
|
||||
FALSE, *data);
|
||||
//test for NULL
|
||||
if (postContext == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->output = new StringReplacer(outputStr, cursorPosition + cursorOffset, data);
|
||||
//test for NULL
|
||||
if (this->output == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,6 +282,11 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
|
||||
* Be careful not to call malloc(0).
|
||||
*/
|
||||
int16_t* indexValue = (int16_t*) uprv_malloc( sizeof(int16_t) * (n > 0 ? n : 1) );
|
||||
//test for NULL
|
||||
if (indexValue == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for (j=0; j<n; ++j) {
|
||||
TransliterationRule* r = (TransliterationRule*) ruleVector->elementAt(j);
|
||||
indexValue[j] = r->getIndexValue();
|
||||
@ -312,6 +317,11 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status)
|
||||
*/
|
||||
delete[] rules; // Contains alias pointers
|
||||
rules = new TransliterationRule*[v.size()];
|
||||
//test for NULL
|
||||
if (rules == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for (j=0; j<v.size(); ++j) {
|
||||
rules[j] = (TransliterationRule*) v.elementAt(j);
|
||||
}
|
||||
|
@ -691,6 +691,11 @@ UBool SimpleTimeZone::inDaylightTime(UDate date, UErrorCode& status) const
|
||||
// and provided only for Java compatibility as of 8/6/97 [LIU].
|
||||
if (U_FAILURE(status)) return FALSE;
|
||||
GregorianCalendar *gc = new GregorianCalendar(*this, status);
|
||||
//test for NULL
|
||||
if (gc == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FALSE;
|
||||
}
|
||||
gc->setTime(date, status);
|
||||
UBool result = gc->inDaylightTime(status);
|
||||
delete gc;
|
||||
|
@ -179,6 +179,11 @@ SimpleDateFormat::SimpleDateFormat(const Locale& locale,
|
||||
delete fSymbols;
|
||||
// This constructor doesn't fail; it uses last resort data
|
||||
fSymbols = new DateFormatSymbols(status);
|
||||
//test for NULL
|
||||
if (fSymbols == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
initialize(locale, status);
|
||||
}
|
||||
@ -267,6 +272,11 @@ void SimpleDateFormat::construct(EStyle timeStyle,
|
||||
|
||||
// create a symbols object from the locale
|
||||
fSymbols = new DateFormatSymbols(locale, status);
|
||||
//test for NULL
|
||||
if (fSymbols == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
UnicodeString str;
|
||||
|
||||
@ -286,6 +296,11 @@ void SimpleDateFormat::construct(EStyle timeStyle,
|
||||
// pattern = MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
|
||||
|
||||
Formattable *timeDateArray = new Formattable[2];
|
||||
//test for NULL
|
||||
if (timeDateArray == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
//timeDateArray[0].setString(UnicodeString(dateTimePatterns[timeStyle]));
|
||||
//timeDateArray[1].setString(UnicodeString(dateTimePatterns[dateStyle]));
|
||||
timeDateArray[0].setString(dateTimePatterns.getStringEx(timeStyle, status));
|
||||
|
@ -310,6 +310,11 @@ SearchIterator * StringSearch::safeClone(void) const
|
||||
(RuleBasedCollator *)&m_collator_,
|
||||
m_breakiterator_,
|
||||
status);
|
||||
//test for NULL
|
||||
if (result == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
result->setOffset(getOffset(), status);
|
||||
result->setMatchStart(m_strsrch_->search->matchedIndex);
|
||||
result->setMatchLength(m_strsrch_->search->matchedLength);
|
||||
|
@ -161,6 +161,11 @@ RuleBasedCollator::construct(const UnicodeString& rules,
|
||||
else {
|
||||
urulestring = new UnicodeString();
|
||||
}
|
||||
//test for NULL
|
||||
if (urulestring == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
dataIsOwned = TRUE;
|
||||
}
|
||||
}
|
||||
@ -584,7 +589,7 @@ RuleBasedCollator::RuleBasedCollator(const Locale& desiredLocale,
|
||||
|
||||
setUCollator(kRootLocaleName, status);
|
||||
if (status == U_ZERO_ERROR) {
|
||||
status = U_USING_DEFAULT_ERROR;
|
||||
status = U_USING_DEFAULT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,6 +604,11 @@ RuleBasedCollator::RuleBasedCollator(const Locale& desiredLocale,
|
||||
else {
|
||||
urulestring = new UnicodeString();
|
||||
}
|
||||
//test for NULL
|
||||
if (urulestring == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
dataIsOwned = TRUE;
|
||||
}
|
||||
|
||||
|
@ -912,6 +912,11 @@ Transliterator* Transliterator::createInstance(const UnicodeString& ID,
|
||||
break;
|
||||
default:
|
||||
t = new CompoundTransliterator(list, parseError, status);
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete t;
|
||||
return NULL;
|
||||
@ -1003,6 +1008,11 @@ Transliterator* Transliterator::createFromRules(const UnicodeString& ID,
|
||||
// ordinary RBT_DATA.
|
||||
t = new RuleBasedTransliterator(ID, parser.orphanData(), TRUE); // TRUE == adopt data object
|
||||
}
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (parser.data == NULL) {
|
||||
// idBlock, no data -- this is an alias. The ID has
|
||||
@ -1018,8 +1028,18 @@ Transliterator* Transliterator::createFromRules(const UnicodeString& ID,
|
||||
// RBT
|
||||
UnicodeString id("_", "");
|
||||
t = new RuleBasedTransliterator(id, parser.orphanData(), TRUE); // TRUE == adopt data object
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
t = new CompoundTransliterator(ID, parser.idBlock, parser.idSplitPoint,
|
||||
t, status);
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
delete t;
|
||||
t = 0;
|
||||
@ -1060,21 +1080,21 @@ UnicodeString& Transliterator::toRules(UnicodeString& rulesSource,
|
||||
UnicodeSet& Transliterator::getSourceSet(UnicodeSet& result) const {
|
||||
handleGetSourceSet(result);
|
||||
if (filter != NULL) {
|
||||
UnicodeSet* filterSet;
|
||||
UBool deleteFilterSet = FALSE;
|
||||
// Most, but not all filters will be UnicodeSets. Optimize for
|
||||
// the high-runner case.
|
||||
if (filter->getDynamicClassID() == UnicodeSet::getStaticClassID()) {
|
||||
filterSet = (UnicodeSet*) filter;
|
||||
} else {
|
||||
filterSet = new UnicodeSet();
|
||||
deleteFilterSet = TRUE;
|
||||
filter->addMatchSetTo(*filterSet);
|
||||
}
|
||||
result.retainAll(*filterSet);
|
||||
if (deleteFilterSet) {
|
||||
delete filterSet;
|
||||
}
|
||||
UnicodeSet* filterSet;
|
||||
UBool deleteFilterSet = FALSE;
|
||||
// Most, but not all filters will be UnicodeSets. Optimize for
|
||||
// the high-runner case.
|
||||
if (filter->getDynamicClassID() == UnicodeSet::getStaticClassID()) {
|
||||
filterSet = (UnicodeSet*) filter;
|
||||
} else {
|
||||
filterSet = new UnicodeSet();
|
||||
deleteFilterSet = TRUE;
|
||||
filter->addMatchSetTo(*filterSet);
|
||||
}
|
||||
result.retainAll(*filterSet);
|
||||
if (deleteFilterSet) {
|
||||
delete filterSet;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -90,6 +90,11 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
|
||||
} else {
|
||||
t = new CompoundTransliterator(ID, aliasID, idSplitPoint,
|
||||
trans, ec);
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
trans = 0; // so we don't delete it later
|
||||
if (compoundFilter) {
|
||||
t->adoptFilter((UnicodeSet*) compoundFilter->clone());
|
||||
@ -172,6 +177,10 @@ Spec::Spec(const UnicodeString& theSpec) : top(theSpec) {
|
||||
CharString topch(top);
|
||||
Locale toploc(topch);
|
||||
res = new ResourceBundle(u_getDataDirectory(), toploc, status);
|
||||
//test for NULL
|
||||
if (res == 0) {
|
||||
return;
|
||||
}
|
||||
if (U_FAILURE(status) ||
|
||||
status == U_USING_DEFAULT_ERROR) {
|
||||
delete res;
|
||||
@ -1012,12 +1021,21 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID
|
||||
return entry->u.prototype->clone();
|
||||
} else if (entry->entryType == Entry::ALIAS) {
|
||||
aliasReturn = new TransliteratorAlias(entry->stringArg);
|
||||
//test for NULL
|
||||
if (aliasReturn == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
return 0;
|
||||
} else if (entry->entryType == Entry::FACTORY) {
|
||||
return entry->u.factory.function(ID, entry->u.factory.context);
|
||||
} else if (entry->entryType == Entry::COMPOUND_RBT) {
|
||||
UnicodeString id("_", "");
|
||||
Transliterator *t = new RuleBasedTransliterator(id, entry->u.data);
|
||||
//test for NULL
|
||||
if (t == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
aliasReturn = new TransliteratorAlias(ID, entry->stringArg, t, entry->intArg, entry->compoundFilter);
|
||||
return 0;
|
||||
}
|
||||
|
@ -251,6 +251,11 @@ UnicodeSet* TransliteratorIDParser::parseGlobalFilter(const UnicodeString& id, i
|
||||
ParsePosition ppos(pos);
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
filter = new UnicodeSet(id, ppos, ec);
|
||||
//test for NULL
|
||||
if (filter == 0) {
|
||||
pos = start;
|
||||
return 0;
|
||||
}
|
||||
if (U_FAILURE(ec)) {
|
||||
delete filter;
|
||||
pos = start;
|
||||
|
@ -920,6 +920,11 @@ UCATableHeader *ucol_assembleTailoringTable(UColTokenParser *src, UErrorCode *st
|
||||
ensure that the script reordering will continue to work.
|
||||
*/
|
||||
UCATableHeader *image = (UCATableHeader *)uprv_malloc(sizeof(UCATableHeader));
|
||||
//test for NULL
|
||||
if (image == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(image, src->UCA->image, sizeof(UCATableHeader));
|
||||
|
||||
for(i = 0; i<src->resultLen; i++) {
|
||||
|
@ -236,7 +236,12 @@ ContractionTable *uprv_cnttab_cloneContraction(ContractionTable *t, UErrorCode *
|
||||
|
||||
r->codePoints = (UChar *)uprv_malloc(sizeof(UChar)*t->size);
|
||||
r->CEs = (uint32_t *)uprv_malloc(sizeof(uint32_t)*t->size);
|
||||
|
||||
|
||||
//Test for NULL
|
||||
if((r->codePoints == NULL) || (r->CEs == NULL)) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->codePoints, t->codePoints, sizeof(UChar)*t->size);
|
||||
uprv_memcpy(r->CEs, t->CEs, sizeof(uint32_t)*t->size);
|
||||
|
||||
@ -251,6 +256,11 @@ uprv_cnttab_clone(CntTable *t, UErrorCode *status) {
|
||||
}
|
||||
int32_t i = 0;
|
||||
CntTable *r = (CntTable *)uprv_malloc(sizeof(CntTable));
|
||||
//Test for NULL
|
||||
if (r == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
r->position = t->position;
|
||||
r->size = t->size;
|
||||
r->capacity = t->capacity;
|
||||
@ -258,6 +268,11 @@ uprv_cnttab_clone(CntTable *t, UErrorCode *status) {
|
||||
r->mapping = t->mapping;
|
||||
|
||||
r->elements = (ContractionTable **)uprv_malloc(t->capacity*sizeof(ContractionTable *));
|
||||
//Test for NULL
|
||||
if (r->elements == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
//uprv_memcpy(r->elements, t->elements, t->capacity*sizeof(ContractionTable *));
|
||||
|
||||
for(i = 0; i<t->size; i++) {
|
||||
@ -266,6 +281,11 @@ uprv_cnttab_clone(CntTable *t, UErrorCode *status) {
|
||||
|
||||
if(t->CEs != NULL) {
|
||||
r->CEs = (uint32_t *)uprv_malloc(t->position*sizeof(uint32_t));
|
||||
//Test for NULL
|
||||
if (r->CEs == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->CEs, t->CEs, t->position*sizeof(uint32_t));
|
||||
} else {
|
||||
r->CEs = NULL;
|
||||
@ -273,6 +293,11 @@ uprv_cnttab_clone(CntTable *t, UErrorCode *status) {
|
||||
|
||||
if(t->codePoints != NULL) {
|
||||
r->codePoints = (UChar *)uprv_malloc(t->position*sizeof(UChar));
|
||||
//Test for NULL
|
||||
if (r->codePoints == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->codePoints, t->codePoints, t->position*sizeof(UChar));
|
||||
} else {
|
||||
r->codePoints = NULL;
|
||||
@ -280,6 +305,11 @@ uprv_cnttab_clone(CntTable *t, UErrorCode *status) {
|
||||
|
||||
if(t->offsets != NULL) {
|
||||
r->offsets = (int32_t *)uprv_malloc(t->size*sizeof(int32_t));
|
||||
//Test for NULL
|
||||
if (r->offsets == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->offsets, t->offsets, t->size*sizeof(int32_t));
|
||||
} else {
|
||||
r->offsets = NULL;
|
||||
|
@ -93,6 +93,11 @@ static int32_t uprv_uca_addExpansion(ExpansionTable *expansions, uint32_t value,
|
||||
}
|
||||
if(expansions->CEs == NULL) {
|
||||
expansions->CEs = (uint32_t *)uprv_malloc(INIT_EXP_TABLE_SIZE*sizeof(uint32_t));
|
||||
//Test for NULL
|
||||
if (expansions->CEs == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
expansions->size = INIT_EXP_TABLE_SIZE;
|
||||
expansions->position = 0;
|
||||
}
|
||||
@ -122,15 +127,41 @@ uhash_freeBlockWrapper(void *obj) {
|
||||
U_CAPI tempUCATable* U_EXPORT2
|
||||
uprv_uca_initTempTable(UCATableHeader *image, UColOptionSet *opts, const UCollator *UCA, UColCETags initTag, UErrorCode *status) {
|
||||
tempUCATable *t = (tempUCATable *)uprv_malloc(sizeof(tempUCATable));
|
||||
//Test for NULL
|
||||
if (t == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
MaxExpansionTable *maxet = (MaxExpansionTable *)uprv_malloc(
|
||||
sizeof(MaxExpansionTable));
|
||||
//Test for NULL
|
||||
if (maxet == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete t;
|
||||
return NULL;
|
||||
}
|
||||
MaxJamoExpansionTable *maxjet = (MaxJamoExpansionTable *)uprv_malloc(
|
||||
sizeof(MaxJamoExpansionTable));
|
||||
//Test for NULL
|
||||
if (maxjet == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete t;
|
||||
delete maxet;
|
||||
return NULL;
|
||||
}
|
||||
t->image = image;
|
||||
t->options = opts;
|
||||
|
||||
t->UCA = UCA;
|
||||
t->expansions = (ExpansionTable *)uprv_malloc(sizeof(ExpansionTable));
|
||||
//Test for NULL
|
||||
if (t->expansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete t;
|
||||
delete maxet;
|
||||
delete maxjet;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memset(t->expansions, 0, sizeof(ExpansionTable));
|
||||
/*t->mapping = ucmpe32_open(UCOL_SPECIAL_FLAG | (initTag<<24), UCOL_SPECIAL_FLAG | (SURROGATE_TAG<<24), UCOL_SPECIAL_FLAG | (LEAD_SURROGATE_TAG<<24), status);*/
|
||||
t->mapping = utrie_open(NULL, NULL, 0x100000, UCOL_SPECIAL_FLAG | (initTag<<24), TRUE); // Do your own mallocs for the structure, array and have linear Latin 1
|
||||
@ -148,8 +179,19 @@ uprv_uca_initTempTable(UCATableHeader *image, UColOptionSet *opts, const UCollat
|
||||
maxet->position = maxet->size - 1;
|
||||
maxet->endExpansionCE =
|
||||
(uint32_t *)uprv_malloc(sizeof(uint32_t) * maxet->size);
|
||||
//Test for NULL
|
||||
if (maxet->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
maxet->expansionCESize =
|
||||
(uint8_t *)uprv_malloc(sizeof(uint8_t) * maxet->size);
|
||||
//Test for NULL
|
||||
if (maxet->expansionCESize == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete maxet->endExpansionCE;
|
||||
return NULL;
|
||||
}
|
||||
/* initialized value */
|
||||
*(maxet->endExpansionCE) = 0;
|
||||
*(maxet->expansionCESize) = 0;
|
||||
@ -171,7 +213,18 @@ uprv_uca_initTempTable(UCATableHeader *image, UColOptionSet *opts, const UCollat
|
||||
maxjet->maxTSize = 1;
|
||||
|
||||
t->unsafeCP = (uint8_t *)uprv_malloc(UCOL_UNSAFECP_TABLE_SIZE);
|
||||
//Test for NULL
|
||||
if (t->unsafeCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
t->contrEndCP = (uint8_t *)uprv_malloc(UCOL_UNSAFECP_TABLE_SIZE);
|
||||
//Test for NULL
|
||||
if (t->contrEndCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
delete t->unsafeCP;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memset(t->unsafeCP, 0, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
uprv_memset(t->contrEndCP, 0, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
return t;
|
||||
@ -184,6 +237,11 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
}
|
||||
|
||||
tempUCATable *r = (tempUCATable *)uprv_malloc(sizeof(tempUCATable));
|
||||
//Test for NULL
|
||||
if (r == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memset(r, 0, sizeof(tempUCATable));
|
||||
|
||||
/* mapping */
|
||||
@ -199,10 +257,20 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
/* expansions */
|
||||
if(t->expansions != NULL) {
|
||||
r->expansions = (ExpansionTable *)uprv_malloc(sizeof(ExpansionTable));
|
||||
//Test for NULL
|
||||
if (r->expansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
r->expansions->position = t->expansions->position;
|
||||
r->expansions->size = t->expansions->size;
|
||||
if(t->expansions->CEs != NULL) {
|
||||
r->expansions->CEs = (uint32_t *)uprv_malloc(sizeof(uint32_t)*t->expansions->size);
|
||||
//Test for NULL
|
||||
if (r->expansions->CEs == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->expansions->CEs, t->expansions->CEs, sizeof(uint32_t)*t->expansions->size);
|
||||
} else {
|
||||
r->expansions->CEs = NULL;
|
||||
@ -216,16 +284,31 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
|
||||
if(t->maxExpansions != NULL) {
|
||||
r->maxExpansions = (MaxExpansionTable *)uprv_malloc(sizeof(MaxExpansionTable));
|
||||
//Test for NULL
|
||||
if (r->maxExpansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
r->maxExpansions->size = t->maxExpansions->size;
|
||||
r->maxExpansions->position = t->maxExpansions->position;
|
||||
if(t->maxExpansions->endExpansionCE != NULL) {
|
||||
r->maxExpansions->endExpansionCE = (uint32_t *)uprv_malloc(sizeof(uint32_t)*t->maxExpansions->size);
|
||||
//Test for NULL
|
||||
if (r->maxExpansions->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->maxExpansions->endExpansionCE, t->maxExpansions->endExpansionCE, t->maxExpansions->size*sizeof(uint32_t));
|
||||
} else {
|
||||
r->maxExpansions->endExpansionCE = NULL;
|
||||
}
|
||||
if(t->maxExpansions->expansionCESize != NULL) {
|
||||
r->maxExpansions->expansionCESize = (uint8_t *)uprv_malloc(sizeof(uint8_t)*t->maxExpansions->size);
|
||||
//Test for NULL
|
||||
if (r->maxExpansions->expansionCESize == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->maxExpansions->expansionCESize, t->maxExpansions->expansionCESize, t->maxExpansions->size*sizeof(uint8_t));
|
||||
} else {
|
||||
r->maxExpansions->expansionCESize = NULL;
|
||||
@ -234,6 +317,11 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
|
||||
if(t->maxJamoExpansions != NULL) {
|
||||
r->maxJamoExpansions = (MaxJamoExpansionTable *)uprv_malloc(sizeof(MaxJamoExpansionTable));
|
||||
//test for NULL
|
||||
if (r->maxJamoExpansions == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
r->maxJamoExpansions->size = t->maxJamoExpansions->size;
|
||||
r->maxJamoExpansions->position = t->maxJamoExpansions->position;
|
||||
r->maxJamoExpansions->maxLSize = t->maxJamoExpansions->maxLSize;
|
||||
@ -241,8 +329,18 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
r->maxJamoExpansions->maxTSize = t->maxJamoExpansions->maxTSize;
|
||||
if(t->maxJamoExpansions->size != 0) {
|
||||
r->maxJamoExpansions->endExpansionCE = (uint32_t *)uprv_malloc(sizeof(uint32_t)*t->maxJamoExpansions->size);
|
||||
//test for NULL
|
||||
if (r->maxJamoExpansions->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->maxJamoExpansions->endExpansionCE, t->maxJamoExpansions->endExpansionCE, t->maxJamoExpansions->size*sizeof(uint32_t));
|
||||
r->maxJamoExpansions->isV = (UBool *)uprv_malloc(sizeof(UBool)*t->maxJamoExpansions->size);
|
||||
//Test for NULL
|
||||
if (r->maxJamoExpansions->isV == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->maxJamoExpansions->isV, t->maxJamoExpansions->isV, t->maxJamoExpansions->size*sizeof(UBool));
|
||||
} else {
|
||||
r->maxJamoExpansions->endExpansionCE = NULL;
|
||||
@ -252,11 +350,21 @@ uprv_uca_cloneTempTable(tempUCATable *t, UErrorCode *status) {
|
||||
|
||||
if(t->unsafeCP != NULL) {
|
||||
r->unsafeCP = (uint8_t *)uprv_malloc(UCOL_UNSAFECP_TABLE_SIZE);
|
||||
//test for NULL
|
||||
if (r->unsafeCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->unsafeCP, t->unsafeCP, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
}
|
||||
|
||||
if(t->contrEndCP != NULL) {
|
||||
r->contrEndCP = (uint8_t *)uprv_malloc(UCOL_UNSAFECP_TABLE_SIZE);
|
||||
//test for NULL
|
||||
if (r->contrEndCP == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
uprv_memcpy(r->contrEndCP, t->contrEndCP, UCOL_UNSAFECP_TABLE_SIZE);
|
||||
}
|
||||
|
||||
@ -317,9 +425,19 @@ int uprv_uca_setMaxExpansion(uint32_t endexpansion,
|
||||
/* we'll always make the first element 0, for easier manipulation */
|
||||
maxexpansion->endExpansionCE =
|
||||
(uint32_t *)uprv_malloc(INIT_EXP_TABLE_SIZE * sizeof(int32_t));
|
||||
//Test for NULL
|
||||
if (maxexpansion->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
*(maxexpansion->endExpansionCE) = 0;
|
||||
maxexpansion->expansionCESize =
|
||||
(uint8_t *)uprv_malloc(INIT_EXP_TABLE_SIZE * sizeof(uint8_t));
|
||||
//test for NULL;
|
||||
if (maxexpansion->expansionCESize == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
*(maxexpansion->expansionCESize) = 0;
|
||||
maxexpansion->size = INIT_EXP_TABLE_SIZE;
|
||||
maxexpansion->position = 0;
|
||||
@ -475,9 +593,19 @@ int uprv_uca_setMaxJamoExpansion(UChar ch,
|
||||
/* we'll always make the first element 0, for easier manipulation */
|
||||
maxexpansion->endExpansionCE =
|
||||
(uint32_t *)uprv_malloc(INIT_EXP_TABLE_SIZE * sizeof(uint32_t));
|
||||
//test for NULL;
|
||||
if (maxexpansion->endExpansionCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
*(maxexpansion->endExpansionCE) = 0;
|
||||
maxexpansion->isV =
|
||||
(UBool *)uprv_malloc(INIT_EXP_TABLE_SIZE * sizeof(UBool));
|
||||
//test for NULL;
|
||||
if (maxexpansion->isV == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
*(maxexpansion->isV) = 0;
|
||||
maxexpansion->size = INIT_EXP_TABLE_SIZE;
|
||||
maxexpansion->position = 0;
|
||||
@ -973,6 +1101,11 @@ uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode *status)
|
||||
// for canonical closure.
|
||||
|
||||
UCAElements *composed = (UCAElements *)uprv_malloc(sizeof(UCAElements));
|
||||
//Test for NULL
|
||||
if (composed == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
uprv_memcpy(composed, element, sizeof(UCAElements));
|
||||
composed->cPoints = composed->uchars;
|
||||
composed->prefix = composed->prefixChars;
|
||||
@ -987,6 +1120,11 @@ uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode *status)
|
||||
} else { // no code points, so this spot is clean
|
||||
element->mapCE = uprv_uca_addPrefix(t, UCOL_NOT_FOUND, element, status);
|
||||
uCE = (UCAElements *)uprv_malloc(sizeof(UCAElements));
|
||||
//Test for NULL
|
||||
if (uCE == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
uprv_memcpy(uCE, element, sizeof(UCAElements));
|
||||
uCE->cPoints = uCE->uchars;
|
||||
uhash_put(t->prefixLookup, uCE, uCE, status);
|
||||
@ -1203,6 +1341,11 @@ uprv_uca_assembleTable(tempUCATable *t, UErrorCode *status) {
|
||||
|
||||
|
||||
dataStart = (uint8_t *)uprv_malloc(toAllocate);
|
||||
//test for NULL
|
||||
if (dataStart == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UCATableHeader *myData = (UCATableHeader *)dataStart;
|
||||
uprv_memcpy(myData, t->image, sizeof(UCATableHeader));
|
||||
|
@ -148,10 +148,20 @@ void ucol_tok_initTokenList(UColTokenParser *src, const UChar *rules, const uint
|
||||
uprv_memset(src, 0, sizeof(UColTokenParser));
|
||||
|
||||
src->source = (UChar *)uprv_malloc(estimatedSize*sizeof(UChar));
|
||||
//Test for NULL
|
||||
if (src->source == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
nSize = unorm_normalize(rules, rulesLength, UNORM_NFD, 0, src->source, estimatedSize, status);
|
||||
if(nSize > estimatedSize || *status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
*status = U_ZERO_ERROR;
|
||||
src->source = (UChar *)uprv_realloc(src->source, (nSize+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar));
|
||||
//test for NULL
|
||||
if (src->source == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
nSize = unorm_normalize(rules, rulesLength, UNORM_NFD, 0, src->source, nSize+UCOL_TOK_EXTRA_RULE_SPACE_SIZE, status);
|
||||
}
|
||||
src->current = src->source;
|
||||
@ -183,12 +193,22 @@ void ucol_tok_initTokenList(UColTokenParser *src, const UChar *rules, const uint
|
||||
uhash_setValueDeleter(src->tailored, uhash_freeBlock);
|
||||
|
||||
src->opts = (UColOptionSet *)uprv_malloc(sizeof(UColOptionSet));
|
||||
//Test for NULL
|
||||
if (src->opts == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
uprv_memcpy(src->opts, UCA->options, sizeof(UColOptionSet));
|
||||
|
||||
// rulesToParse = src->source;
|
||||
src->lh = 0;
|
||||
src->lh = (UColTokListHeader *)uprv_malloc(512*sizeof(UColTokListHeader));
|
||||
//Test for NULL
|
||||
if (src->lh == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
src->resultLen = 0;
|
||||
|
||||
UCAConstants *consts = (UCAConstants *)((uint8_t *)src->UCA->image + src->UCA->image->UCAConsts);
|
||||
@ -946,6 +966,11 @@ static UColToken *ucol_tok_initAReset(UColTokenParser *src, UChar *expand, uint3
|
||||
UParseError *parseError, UErrorCode *status) {
|
||||
/* do the reset thing */
|
||||
UColToken *sourceToken = (UColToken *)uprv_malloc(sizeof(UColToken));
|
||||
//test for NULL
|
||||
if (sourceToken == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
sourceToken->rulesToParse = src->source;
|
||||
sourceToken->source = src->parsedToken.charsLen << 24 | src->parsedToken.charsOffset;
|
||||
sourceToken->expansion = src->parsedToken.extensionLen << 24 | src->parsedToken.extensionOffset;
|
||||
@ -1139,6 +1164,11 @@ uint32_t ucol_tok_assembleTokenList(UColTokenParser *src, UParseError *parseErro
|
||||
if(sourceToken == NULL) {
|
||||
/* If sourceToken is null, create new one, */
|
||||
sourceToken = (UColToken *)uprv_malloc(sizeof(UColToken));
|
||||
//test for NULL
|
||||
if (sourceToken == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
sourceToken->rulesToParse = src->source;
|
||||
sourceToken->source = src->parsedToken.charsLen << 24 | src->parsedToken.charsOffset;
|
||||
|
||||
|
@ -53,6 +53,11 @@ ucol_openElements(const UCollator *coll,
|
||||
}
|
||||
|
||||
result = (UCollationElements *)uprv_malloc(sizeof(UCollationElements));
|
||||
//test for NULL
|
||||
if (result == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result->reset_ = TRUE;
|
||||
result->isWritable = FALSE;
|
||||
|
@ -327,6 +327,11 @@ utrans_setFilter(UTransliterator* trans,
|
||||
// Create read only alias of filterPattern:
|
||||
UnicodeString pat(filterPatternLen < 0, filterPattern, filterPatternLen);
|
||||
filter = new UnicodeSet(pat, *status);
|
||||
//test for NULL
|
||||
if (filter == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
if (U_FAILURE(*status)) {
|
||||
delete filter;
|
||||
filter = NULL;
|
||||
|
@ -290,7 +290,13 @@ inline int32_t ICULayoutEngine::layoutString(const UnicodeString &str,
|
||||
int32_t glyphCount = 0;
|
||||
int32_t max = str.length();
|
||||
UChar *chars = new UChar[max];
|
||||
|
||||
|
||||
//test for NULL
|
||||
if(chars == NULL) {
|
||||
success = LE_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
str.extract(0, max, chars);
|
||||
|
||||
// NOTE: call reset() so that clients can safely reuse
|
||||
|
@ -324,6 +324,11 @@ main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
symPrefix = (char *) uprv_malloc(uprv_strlen(entrypointName) + 2);
|
||||
//test for NULL
|
||||
if (symPrefix == NULL) {
|
||||
sprintf(buffer, "U_MEMORY_ALLOCATION_ERROR");
|
||||
exit(U_MEMORY_ALLOCATION_ERROR);
|
||||
}
|
||||
uprv_strcpy(symPrefix, entrypointName);
|
||||
uprv_strcat(symPrefix, "_");
|
||||
|
||||
|
@ -214,7 +214,12 @@ processFile(const char *filename, const char *cp, const char *inputDir, const ch
|
||||
*/
|
||||
int32_t filenameSize = filenameBegin - filename + 1;
|
||||
inputDirBuf = uprv_strncpy((char *)uprv_malloc(filenameSize), filename, filenameSize);
|
||||
inputDirBuf[filenameSize - 1] = 0;
|
||||
//test for NULL
|
||||
if(inputDirBuf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto finish;
|
||||
}
|
||||
inputDirBuf[filenameSize - 1] = 0;
|
||||
inputDir = inputDirBuf;
|
||||
}
|
||||
in = T_FileStream_open(filename, "rb");
|
||||
@ -223,6 +228,11 @@ processFile(const char *filename, const char *cp, const char *inputDir, const ch
|
||||
int32_t filelen = (int32_t)uprv_strlen(filename);
|
||||
if(inputDir[dirlen-1] != U_FILE_SEP_CHAR) {
|
||||
openFileName = (char *) uprv_malloc(dirlen + filelen + 2);
|
||||
//test for NULL
|
||||
if(openFileName == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto finish;
|
||||
}
|
||||
openFileName[0] = '\0';
|
||||
/*
|
||||
* append the input dir to openFileName if the first char in
|
||||
@ -243,6 +253,11 @@ processFile(const char *filename, const char *cp, const char *inputDir, const ch
|
||||
uprv_strcat(openFileName, filename);
|
||||
} else {
|
||||
openFileName = (char *) uprv_malloc(dirlen + filelen + 1);
|
||||
//test for NULL
|
||||
if(openFileName == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto finish;
|
||||
}
|
||||
uprv_strcpy(openFileName, inputDir);
|
||||
uprv_strcat(openFileName, filename);
|
||||
}
|
||||
|
@ -386,6 +386,12 @@ parseUCARules(char *tag, uint32_t startline, UErrorCode *status)
|
||||
* is not known in UTF-8 byte stream
|
||||
*/
|
||||
UChar *pTarget = (UChar *) uprv_malloc(sizeof(UChar) * size);
|
||||
//test for NULL
|
||||
if(pTarget == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
T_FileStream_close(file);
|
||||
return NULL;
|
||||
}
|
||||
UChar *target = pTarget;
|
||||
UChar *targetLimit = pTarget + size;
|
||||
|
||||
@ -1084,6 +1090,11 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
|
||||
if (inputdir[inputdirLength - 1] != U_FILE_SEP_CHAR)
|
||||
{
|
||||
fullname = (char *) uprv_malloc(inputdirLength + count + 2);
|
||||
//test for NULL
|
||||
if(fullname == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uprv_strcpy(fullname, inputdir);
|
||||
|
||||
@ -1095,7 +1106,12 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
|
||||
else
|
||||
{
|
||||
fullname = (char *) uprv_malloc(inputdirLength + count + 1);
|
||||
|
||||
//test for NULL
|
||||
if(fullname == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uprv_strcpy(fullname, inputdir);
|
||||
uprv_strcat(fullname, filename);
|
||||
}
|
||||
@ -1113,6 +1129,12 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
|
||||
|
||||
len = T_FileStream_size(file);
|
||||
data = uprv_malloc(len);
|
||||
//test for NULL
|
||||
if(data == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
T_FileStream_close (file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
T_FileStream_read (file, data, len);
|
||||
T_FileStream_close (file);
|
||||
|
@ -40,8 +40,8 @@ static const char copyRight[] =
|
||||
" *\n"
|
||||
" *******************************************************************************\n"
|
||||
" * $Source: /xsrl/Nsvn/icu/icu/source/tools/genrb/wrtjava.c,v $ \n"
|
||||
" * $Date: 2002/05/21 23:29:56 $ \n"
|
||||
" * $Revision: 1.12 $ \n"
|
||||
" * $Date: 2002/06/29 09:19:46 $ \n"
|
||||
" * $Revision: 1.13 $ \n"
|
||||
" *******************************************************************************\n"
|
||||
" */\n\n";
|
||||
static const char warningMsg[] =
|
||||
@ -256,6 +256,12 @@ str_write_java( uint16_t* src, int32_t srcLen, UErrorCode *status){
|
||||
uint32_t length = srcLen*8;
|
||||
uint32_t bufLen = 0;
|
||||
char* buf = (char*) malloc(sizeof(char)*length);
|
||||
//test for NULL
|
||||
if(buf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
memset(buf,0,length);
|
||||
|
||||
bufLen = uCharsToChars(buf,length,src,srcLen,status);
|
||||
@ -318,6 +324,11 @@ string_write_java(struct SResource *res,UErrorCode *status) {
|
||||
str_write_java(res->u.fString.fChars,res->u.fString.fLength,status);
|
||||
if(uprv_strcmp(srBundle->fKeys+res->fKey,"Rule")==0){
|
||||
UChar* buf = (UChar*) uprv_malloc(sizeof(UChar)*res->u.fString.fLength);
|
||||
//test for NULL
|
||||
if(buf == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
uprv_memcpy(buf,res->u.fString.fChars,res->u.fString.fLength);
|
||||
uprv_free(buf);
|
||||
}
|
||||
@ -514,6 +525,12 @@ bin_write_java( struct SResource *res, UErrorCode *status) {
|
||||
/***************** Test Roundtripping *********************/
|
||||
int32_t myTargetLen = rleStringToUCharArray(target,tgtLen,NULL,0,status);
|
||||
uint16_t* myTarget = (uint16_t*) malloc(sizeof(uint16_t) * myTargetLen);
|
||||
//test for NULL
|
||||
if(myTarget == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
int i=0;
|
||||
int32_t retVal=0;
|
||||
uint16_t* saveSrc = (uint16_t*)res->u.fBinaryValue.fData;
|
||||
@ -553,6 +570,11 @@ bin_write_java( struct SResource *res, UErrorCode *status) {
|
||||
{
|
||||
int32_t myTargetLen = rleStringToByteArray(target,tgtLen,NULL,0,status);
|
||||
uint8_t* myTarget = (uint8_t*) malloc(sizeof(uint8_t) * myTargetLen);
|
||||
//test for NULL
|
||||
if(myTarget == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
int i=0;
|
||||
int32_t retVal=0;
|
||||
|
||||
|
@ -319,6 +319,10 @@ void gentz::fixupNameToEquiv() {
|
||||
|
||||
// First make a list that maps indices to offsets
|
||||
uint32_t *offsets = (uint32_t*) uprv_malloc(sizeof(uint32_t) * equivCount);
|
||||
//test for NULL
|
||||
if(offsets == 0) {
|
||||
die("Out of memory");
|
||||
}
|
||||
offsets[0] = header.equivTableDelta;
|
||||
if (offsets[0] % 4 != 0) {
|
||||
die("Header size is not 4-aligned");
|
||||
|
@ -598,7 +598,20 @@ write_uca_table(const char *filename,
|
||||
UCAElements *element = NULL;
|
||||
UChar variableTopValue = 0;
|
||||
UCATableHeader *myD = (UCATableHeader *)uprv_malloc(sizeof(UCATableHeader));
|
||||
//test for NULL
|
||||
if(myD == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
fclose(data);
|
||||
return 0;
|
||||
}
|
||||
UColOptionSet *opts = (UColOptionSet *)uprv_malloc(sizeof(UColOptionSet));
|
||||
//test for NULL
|
||||
if(opts == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(myD);
|
||||
fclose(data);
|
||||
return 0;
|
||||
}
|
||||
UChar contractionCEs[256][3];
|
||||
uint32_t noOfContractions = 0;
|
||||
UCAConstants consts = {
|
||||
|
@ -128,6 +128,10 @@ CharList *pkg_prependToList(CharList *l, const char *str)
|
||||
{
|
||||
CharList *newList;
|
||||
newList = uprv_malloc(sizeof(CharList));
|
||||
//test for NULL
|
||||
if(newList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
newList->str = str;
|
||||
newList->next = l;
|
||||
return newList;
|
||||
|
Loading…
Reference in New Issue
Block a user