ICU-770 Memory cleanup

X-SVN-Rev: 6274
This commit is contained in:
George Rhoten 2001-10-17 02:19:48 +00:00
parent 1735cf4764
commit 984b83e80a
3 changed files with 62 additions and 48 deletions

View File

@ -172,9 +172,9 @@ const static char cnt2[][10] = {
static void IncompleteCntTest( )
{
UErrorCode status = U_ZERO_ERROR;
UChar *temp=(UChar*)malloc(sizeof(UChar) * 90);
UChar *t1 =(UChar*)malloc(sizeof(UChar) * 90);
UChar *t2 =(UChar*)malloc(sizeof(UChar) * 90);
UChar temp[90];
UChar t1[90];
UChar t2[90];
UCollator *coll = NULL;
uint32_t i = 0, j = 0;
@ -274,8 +274,8 @@ const static char nonignorable[][20] = {
static void BlackBirdTest( ) {
UErrorCode status = U_ZERO_ERROR;
UChar *t1 =(UChar*)malloc(sizeof(UChar) * 90);
UChar *t2 =(UChar*)malloc(sizeof(UChar) * 90);
UChar t1[90];
UChar t2[90];
uint32_t i = 0, j = 0;
uint32_t size = 0;
@ -1447,6 +1447,10 @@ static void TestChMove(void) {
}
}
}
else {
log_err("Can't open collator");
}
ucol_close(coll);
}
const static char impTest[][20] = {
@ -1484,6 +1488,10 @@ static void TestImplicitTailoring(void) {
}
}
}
else {
log_err("Can't open collator");
}
ucol_close(coll);
}
static void TestFCDProblem(void) {
@ -1504,6 +1512,7 @@ static void TestFCDProblem(void) {
ucol_setAttribute(coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
doTest(coll, t1, t2, UCOL_EQUAL);
ucol_close(coll);
}
#define NORM_BUFFER_TEST_LEN 32
@ -2362,6 +2371,8 @@ static void TestCompressOverlap() {
}
tempptr ++;
}
ucol_close(coll);
}
static void TestCyrillicTailoring(void) {
@ -2819,6 +2830,7 @@ static void TestVariableTopSetting() {
if(status != U_INTERNAL_PROGRAM_ERROR) {
log_err("Bad reaction to passed error!\n");
}
uprv_free(rulesCopy);
ucol_close(coll);
}
@ -3178,7 +3190,7 @@ static void TestPrefixCompose() {
UErrorCode status = U_ZERO_ERROR;
uint32_t i = 0;
UCollationElements *it = NULL;
uint32_t CE;
/* uint32_t CE;*/
UChar string[256];
uint32_t uStringLen;
UCollator *coll = NULL;

View File

@ -85,9 +85,9 @@ static void
TestDeprecatedCollationAPI(void)
{
UErrorCode status = U_ZERO_ERROR;
UChar *temp=(UChar*)malloc(sizeof(UChar) * 90);
UChar *t1 =(UChar*)malloc(sizeof(UChar) * 90);
UChar *t2 =(UChar*)malloc(sizeof(UChar) * 90);
UChar temp[90];
UChar t1[90];
UChar t2[90];
UCollator *coll = NULL;
uint32_t i = 0, j = 0;
@ -284,6 +284,8 @@ TestDeprecatedDateFmtAPI(void)
else
log_verbose("PASS: creating dateformat using udat_openPattern() succesful\n");
udat_close(def);
udat_close(fr_pat);
}
static void

View File

@ -200,52 +200,52 @@ static void TestUCMPE32API(){
log_err("ERROR: ucmpe32_open() failed\n");
status = U_ZERO_ERROR;
} else {
fillup(ucmpe32Array);
query(ucmpe32Array);
log_verbose("Testing ucmpe32_clone()\n");
ucmpe32Clone=ucmpe32_clone(ucmpe32Array, &status);
if(U_FAILURE(status) || ucmpe32Clone == NULL){
log_err("ERROR: ucmpe32_clone() failed\n");
status = U_ZERO_ERROR;
} else {
query(ucmpe32Clone);
ucmpe32_close(ucmpe32Clone);
ucmpe32Clone = NULL;
}
log_verbose("Testing ucmpe32_flattenMem()\n");
{
UMemoryStream *MS = uprv_mstrm_openNew(65536);
int32_t size = ucmpe32_flattenMem(ucmpe32Array, MS);
int32_t len = 0;
const uint8_t *buff = NULL;
if(size > 0) {
log_err("Managed to flatten uncompacted array\n");
}
ucmpe32_compact(ucmpe32Array);
fillup(ucmpe32Array);
query(ucmpe32Array);
/* try after compacting */
size = ucmpe32_flattenMem(ucmpe32Array, MS);
buff = uprv_mstrm_getBuffer(MS, &len);
if(size == 0 || len == 0 || buff == NULL) {
log_err("Unable to flatten!\n");
log_verbose("Testing ucmpe32_clone()\n");
ucmpe32Clone=ucmpe32_clone(ucmpe32Array, &status);
if(U_FAILURE(status) || ucmpe32Clone == NULL){
log_err("ERROR: ucmpe32_clone() failed\n");
status = U_ZERO_ERROR;
} else {
log_verbose("Testing ucmpe32_openFromData()\n");
ucmpe32Clone = ucmpe32_openFromData(&buff, &status);
if(U_FAILURE(status) || ucmpe32Clone == NULL){
log_err("ERROR: ucmpe32_openFromData() failed\n");
status = U_ZERO_ERROR;
} else {
query(ucmpe32Clone);
ucmpe32_close(ucmpe32Clone);
ucmpe32Clone = NULL;
}
}
}
ucmpe32_close(ucmpe32Array);
log_verbose("Testing ucmpe32_flattenMem()\n");
{
UMemoryStream *MS = uprv_mstrm_openNew(65536);
int32_t size = ucmpe32_flattenMem(ucmpe32Array, MS);
int32_t len = 0;
const uint8_t *buff = NULL;
if(size > 0) {
log_err("Managed to flatten uncompacted array\n");
}
ucmpe32_compact(ucmpe32Array);
query(ucmpe32Array);
/* try after compacting */
size = ucmpe32_flattenMem(ucmpe32Array, MS);
buff = uprv_mstrm_getBuffer(MS, &len);
if(size == 0 || len == 0 || buff == NULL) {
log_err("Unable to flatten!\n");
} else {
log_verbose("Testing ucmpe32_openFromData()\n");
ucmpe32Clone = ucmpe32_openFromData(&buff, &status);
if(U_FAILURE(status) || ucmpe32Clone == NULL){
log_err("ERROR: ucmpe32_openFromData() failed\n");
status = U_ZERO_ERROR;
} else {
query(ucmpe32Clone);
ucmpe32_close(ucmpe32Clone);
ucmpe32Clone = NULL;
}
}
uprv_mstrm_close(MS);
}
ucmpe32_close(ucmpe32Array);
}
}