ICU-6695 Use realloc instead of malloc when increasing the size of the array and also update pointers to the new array. Increase the curCase value check to call code that were skipped during ucnvseltst.

X-SVN-Rev: 25289
This commit is contained in:
Michael Ow 2009-01-22 20:10:47 +00:00
parent 68858f5870
commit 798386a4ff
2 changed files with 22 additions and 21 deletions

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2002-2008, International Business Machines
* Copyright (C) 2002-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -212,12 +212,13 @@ upvec_setValue(UPropsVectors *pv,
*pErrorCode=U_INTERNAL_PROGRAM_ERROR;
return;
}
newVectors=(uint32_t *)uprv_malloc(newMaxRows*columns*4);
newVectors=(uint32_t *)uprv_realloc(pv->v, newMaxRows*columns*4);
if(newVectors==NULL) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return;
}
uprv_free(pv->v);
firstRow = newVectors+(firstRow-pv->v);
lastRow = newVectors+(lastRow-pv->v);
pv->v=newVectors;
pv->maxRows=newMaxRows;
}

View File

@ -1,12 +1,12 @@
/********************************************************************
* Copyright (c) 1997-2008, International Business Machines
* Copyright (c) 1997-2009, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************
*
* File UCNVSELTST.C
*
* Modification History:
* Name Description
* Name Description
* MOHAMED ELDAWY Creation
********************************************************************
*/
@ -42,7 +42,7 @@ static FILE *fopenOrError(const char *filename) {
strcpy(fnbuf, directory);
strcat(fnbuf, TDSRCPATH);
strcat(fnbuf, filename);
f = fopen(fnbuf, "rb");
if(f == NULL) {
@ -167,10 +167,10 @@ static void TestConversionUTF8()
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, -1,
1, 5, 9, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, 1, -1};
@ -208,7 +208,7 @@ static void TestConversionUTF8()
if(encodingsTestCases[testCaseIdx] != -1) continue;
curCase++;
if(QUICK && curCase > 2)
if(QUICK && curCase > 4)
break;
status = U_ZERO_ERROR;
@ -236,7 +236,7 @@ static void TestConversionUTF8()
return;
}
counter = 0;
while(fread(&c, sizeof(c), 1, f1) > 0)
while(fread(&c, sizeof(c), 1, f1) > 0)
counter++;
fclose(f1);
text = (char*)uprv_malloc((counter+1));
@ -406,7 +406,7 @@ void verifyResultUTF16(const UChar* const s, const char** encodings, int32_t num
resultsManually[findIndex(encodings[i])] = TRUE;
unicode_point_set = uset_open(1, 0);
unicode_point_set = uset_open(1, 0);
test_converter = ucnv_open(encodings[i], &status);
ucnv_getUnicodeSet(test_converter, unicode_point_set,
whichSet, &status);
@ -445,7 +445,7 @@ void verifyResultUTF16(const UChar* const s, const char** encodings, int32_t num
/* does selectForUTF16() work well? */
static void TestConversionUTF16()
{
/*
/*
* test cases are separated by a -1
* each line is one test case including encodings to check for
* I'd like to generate this array randomly but not sure if this is an allowed practice in ICU
@ -455,10 +455,10 @@ static void TestConversionUTF16()
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, -1,
1, 5, 9, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, 1, -1};
@ -500,7 +500,7 @@ static void TestConversionUTF16()
if(encodingsTestCases[testCaseIdx] != -1) continue;
curCase++;
if(QUICK && curCase > 2)
if(QUICK && curCase > 137052384)
break;
status = U_ZERO_ERROR;
@ -678,7 +678,7 @@ static void TestConversionUTF16()
/* does selectForUTF16() work well? */
static void TestSerializationAndUnserialization()
{
/*
/*
* test cases are separated by a -1
* each line is one test case including encodings to check for
* I'd like to generate this array randomly but not sure if this is an allowed practice in ICU
@ -688,10 +688,10 @@ static void TestSerializationAndUnserialization()
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, -1,
1, 5, 9, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, 1, -1};
@ -712,7 +712,7 @@ static void TestSerializationAndUnserialization()
curCase = 0;
for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++)
for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++)
for(testCaseIdx = 0, prev=0, curCase =0 ; testCaseIdx < test_case_count ; testCaseIdx++)
{
UErrorCode status;
@ -736,7 +736,7 @@ static void TestSerializationAndUnserialization()
curCase++;
if(QUICK && curCase > 2)
if(QUICK && curCase > 146587872)
break;
status = U_ZERO_ERROR;
@ -856,7 +856,7 @@ static void TestSerializationAndUnserialization()
/* ////////////////////////////////////////////////////////////////////////// */
/* try fallback mapping! */
for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++)
for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++)
for(testCaseIdx = 0, prev=0, curCase=0 ; testCaseIdx < test_case_count ; testCaseIdx++)
{
UErrorCode status;