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. * Corporation and others. All Rights Reserved.
* *
******************************************************************************* *******************************************************************************
@ -212,12 +212,13 @@ upvec_setValue(UPropsVectors *pv,
*pErrorCode=U_INTERNAL_PROGRAM_ERROR; *pErrorCode=U_INTERNAL_PROGRAM_ERROR;
return; return;
} }
newVectors=(uint32_t *)uprv_malloc(newMaxRows*columns*4); newVectors=(uint32_t *)uprv_realloc(pv->v, newMaxRows*columns*4);
if(newVectors==NULL) { if(newVectors==NULL) {
*pErrorCode=U_MEMORY_ALLOCATION_ERROR; *pErrorCode=U_MEMORY_ALLOCATION_ERROR;
return; return;
} }
uprv_free(pv->v); firstRow = newVectors+(firstRow-pv->v);
lastRow = newVectors+(lastRow-pv->v);
pv->v=newVectors; pv->v=newVectors;
pv->maxRows=newMaxRows; pv->maxRows=newMaxRows;
} }

View File

@ -1,5 +1,5 @@
/******************************************************************** /********************************************************************
* Copyright (c) 1997-2008, International Business Machines * Copyright (c) 1997-2009, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
******************************************************************** ********************************************************************
* *
@ -208,7 +208,7 @@ static void TestConversionUTF8()
if(encodingsTestCases[testCaseIdx] != -1) continue; if(encodingsTestCases[testCaseIdx] != -1) continue;
curCase++; curCase++;
if(QUICK && curCase > 2) if(QUICK && curCase > 4)
break; break;
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
@ -500,7 +500,7 @@ static void TestConversionUTF16()
if(encodingsTestCases[testCaseIdx] != -1) continue; if(encodingsTestCases[testCaseIdx] != -1) continue;
curCase++; curCase++;
if(QUICK && curCase > 2) if(QUICK && curCase > 137052384)
break; break;
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
@ -736,7 +736,7 @@ static void TestSerializationAndUnserialization()
curCase++; curCase++;
if(QUICK && curCase > 2) if(QUICK && curCase > 146587872)
break; break;
status = U_ZERO_ERROR; status = U_ZERO_ERROR;