ICU-1953 remove // comments from C code. Fix indentation, removed tabs.

X-SVN-Rev: 8984
This commit is contained in:
Eric Mader 2002-07-01 18:04:55 +00:00
parent d160acc6e2
commit 898fd409f9
9 changed files with 172 additions and 133 deletions

View file

@ -176,9 +176,12 @@ ucmp8_openAdopt(uint16_t *indexArray,
int32_t count)
{
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
//test for NULL
if(this_obj == NULL)
return NULL;
/* test for NULL */
if(this_obj == NULL) {
return NULL;
}
ucmp8_initAdopt(this_obj, indexArray, newValues, count);
this_obj->fIAmOwned = FALSE;
return this_obj;
@ -189,11 +192,14 @@ ucmp8_openAlias(uint16_t *indexArray,
int8_t *newValues,
int32_t count)
{
CompactByteArray* this_obj = (CompactByteArray*) uprv_malloc(sizeof(CompactByteArray));
//test for NULL
if(this_obj == NULL)
return NULL;
ucmp8_initAlias(this_obj, indexArray, newValues, count);
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;
}

View file

@ -74,9 +74,7 @@ _HZOpen(UConverter *cnv, const char *name,const char *locale,uint32_t options, U
((UConverterDataHZ*)cnv->extraInfo)->targetIndex = 0;
((UConverterDataHZ*)cnv->extraInfo)->sourceIndex = 0;
((UConverterDataHZ*)cnv->extraInfo)->isTargetUCharDBCS = FALSE;
}
//test for NULL
else {
} else { /* test for NULL */
*errorCode = U_MEMORY_ALLOCATION_ERROR;
return;
}

View file

@ -516,11 +516,13 @@ 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
/* test for NULL */
if(chAlias == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
return NULL;
}
u_UCharsToChars(alias, chAlias, len);
chAlias[len] = 0;
@ -620,11 +622,13 @@ 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;
}
/* test for NULL */
if (resB == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
ures_setIsStackObject(resB, FALSE);
resB->fResPath = NULL;
} else {
@ -677,11 +681,12 @@ 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;
}
/* test for NULL */
if (r == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
} else {
isStackObject = ures_isStackObject(r);
if(U_FAILURE(*status)) {
@ -690,11 +695,12 @@ 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;
}
/* test for NULL */
if (r == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
}
}
uprv_memcpy(r, original, sizeof(UResourceBundle));
@ -1047,11 +1053,13 @@ ures_findResource(const char* path, UResourceBundle *fillIn, UErrorCode *status)
return result;
}
pathToResource = (char *)uprv_malloc((uprv_strlen(path)+1)*sizeof(char));
//test for NULL
/*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 */
@ -1478,11 +1486,12 @@ 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;
}
/* test for NULL */
if (path == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_wcstombs(path, myPath, pathSize);
@ -1506,11 +1515,12 @@ 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;
}
/* test for NULL */
if(path == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
u_UCharsToChars(myPath, path, pathSize);

View file

@ -501,11 +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;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
@ -545,11 +546,11 @@ 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;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
@ -574,11 +575,11 @@ 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;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
@ -643,11 +644,11 @@ expandLamAlef(UChar *dest, int32_t sourceLength,
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;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (destSize+1)*U_SIZEOF_UCHAR);
@ -685,11 +686,11 @@ 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;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
@ -726,11 +727,11 @@ expandLamAlef(UChar *dest, int32_t sourceLength,
*/
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
//Test for NULL
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
@ -1025,11 +1026,11 @@ u_shapeArabic(const UChar *source, int32_t sourceLength,
} else {
tempbuffer = (UChar *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
//Test for NULL
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
}
uprv_memcpy(tempbuffer, source, sourceLength*U_SIZEOF_UCHAR);
if(sourceLength<outputSize) {

View file

@ -324,11 +324,13 @@ 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);
}
/* test for NULL */
if (symPrefix == NULL) {
sprintf(buffer, "U_MEMORY_ALLOCATION_ERROR");
exit(U_MEMORY_ALLOCATION_ERROR);
}
uprv_strcpy(symPrefix, entrypointName);
uprv_strcat(symPrefix, "_");

View file

@ -214,12 +214,14 @@ 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);
//test for NULL
if(inputDirBuf == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
goto finish;
}
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");
@ -228,11 +230,13 @@ 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;
}
/* 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
@ -253,11 +257,13 @@ 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;
}
/* test for NULL */
if(openFileName == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
goto finish;
}
uprv_strcpy(openFileName, inputDir);
uprv_strcat(openFileName, filename);
}

View file

@ -385,16 +385,18 @@ parseUCARules(char *tag, uint32_t startline, UErrorCode *status)
* since the actual size needed for storing UChars
* 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 *pTarget = (UChar *) uprv_malloc(sizeof(UChar) * size);
UChar *target = pTarget;
UChar *targetLimit = pTarget + size;
/* test for NULL */
if(pTarget == NULL)
{
*status = U_MEMORY_ALLOCATION_ERROR;
T_FileStream_close(file);
return NULL;
}
ucbuf = ucbuf_open(file, NULL,getShowWarning(), status);
if (U_FAILURE(*status)) {
@ -1090,11 +1092,13 @@ 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;
}
/* test for NULL */
if(fullname == NULL)
{
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_strcpy(fullname, inputdir);
@ -1106,11 +1110,13 @@ 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;
}
/* test for NULL */
if(fullname == NULL)
{
*status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_strcpy(fullname, inputdir);
uprv_strcat(fullname, filename);
@ -1129,12 +1135,14 @@ 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;
}
/* 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);

View 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/06/29 09:19:46 $ \n"
" * $Revision: 1.13 $ \n"
" * $Date: 2002/07/01 18:04:24 $ \n"
" * $Revision: 1.14 $ \n"
" *******************************************************************************\n"
" */\n\n";
static const char warningMsg[] =
@ -256,7 +256,8 @@ 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
/* test for NULL */
if(buf == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
@ -324,11 +325,13 @@ 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;
}
/* 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);
}
@ -525,7 +528,8 @@ 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
/* test for NULL */
if(myTarget == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
@ -570,11 +574,13 @@ 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
/* test for NULL */
if(myTarget == NULL) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
int i=0;
int32_t retVal=0;

View file

@ -128,10 +128,12 @@ CharList *pkg_prependToList(CharList *l, const char *str)
{
CharList *newList;
newList = uprv_malloc(sizeof(CharList));
//test for NULL
/* test for NULL */
if(newList == NULL) {
return NULL;
return NULL;
}
newList->str = str;
newList->next = l;
return newList;