ICU-2135 fix memory problems in genrb after running through valgrind

X-SVN-Rev: 10473
This commit is contained in:
Eric Mader 2002-12-04 02:38:39 +00:00
parent dc677a4338
commit 99cb3d5c6d
2 changed files with 10 additions and 8 deletions

View file

@ -701,7 +701,7 @@ static struct SResource *
realParseTable(struct SResource *table, char *tag, uint32_t startline, UErrorCode *status)
{
struct SResource *member = NULL;
struct UString *tokenValue;
struct UString *tokenValue=NULL;
enum ETokenType token;
char subtag[1024];
uint32_t line;
@ -1121,7 +1121,7 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
char *filename;
uint32_t line;
char *fullname = NULL;
int32_t numRead = 0;
filename = getInvariantString(&line, status);
if (U_FAILURE(*status))
@ -1196,8 +1196,8 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
}
len = T_FileStream_size(file);
data = uprv_malloc(len);
data = (uint8_t*)uprv_malloc(len* sizeof(uint8_t)* 3);
uprv_memset(data,0xFF, len *3);
/* test for NULL */
if(data == NULL)
{
@ -1206,7 +1206,7 @@ parseImport(char *tag, uint32_t startline, UErrorCode *status)
return NULL;
}
T_FileStream_read (file, data, len);
numRead = T_FileStream_read (file, data, len);
T_FileStream_close (file);
result = bin_open(bundle, tag, len, data, fullname, status);

View file

@ -340,7 +340,9 @@ void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *out
}
mem = udata_create(outputDir, "res", dataName, &dataInfo, (gIncludeCopyright==TRUE)? U_COPYRIGHT_STRING:NULL, status);
if(U_FAILURE(status)){
return;
}
pad = calcPadding(bundle->fKeyPoint);
usedOffset = sizeof(uint32_t) + bundle->fKeyPoint + pad ; /*this is how much root and keys are taking up*/
@ -459,7 +461,7 @@ struct SResource *string_open(struct SRBRoot *bundle, char *tag, UChar *value, i
}
uprv_memcpy(res->u.fString.fChars, value, sizeof(UChar) * (len + 1));
res->fSize = sizeof(int32_t) + sizeof(UChar) * (len + 1);
res->fSize = sizeof(int32_t) + sizeof(UChar) * (len);
return res;
}
@ -598,7 +600,7 @@ struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t len
res->u.fBinaryValue.fLength = length;
res->u.fBinaryValue.fFileName = NULL;
if(fileName!=NULL && uprv_strcmp(fileName, "") !=0){
res->u.fBinaryValue.fFileName = (char*) uprv_malloc(sizeof(char) * uprv_strlen(fileName));
res->u.fBinaryValue.fFileName = (char*) uprv_malloc(sizeof(char) * (uprv_strlen(fileName)+1));
uprv_strcpy(res->u.fBinaryValue.fFileName,fileName);
}
if (length > 0) {