ICU-6063 fix memory leak. Also, rename a variable for clarity

X-SVN-Rev: 23025
This commit is contained in:
Steven R. Loomis 2007-12-05 21:13:44 +00:00
parent 155de1eafe
commit c6184cf96d
2 changed files with 9 additions and 6 deletions

View File

@ -443,7 +443,7 @@ void checkBreakBoundary(const UStringSearch *strsrch, int32_t * /*start*/,
int32_t *end)
{
#if !UCONFIG_NO_BREAK_ITERATION
UBreakIterator *breakiterator = strsrch->search->_breakIter_;
UBreakIterator *breakiterator = strsrch->search->internalBreakIter;
if (breakiterator) {
int32_t matchend = *end;
//int32_t matchstart = *start;
@ -2603,7 +2603,7 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator(
result->search->breakIter = breakiter;
#if !UCONFIG_NO_BREAK_ITERATION
result->search->_breakIter_ = ubrk_open(UBRK_CHARACTER, ucol_getLocale(result->collator, ULOC_VALID_LOCALE, status), text, textlength, status);
result->search->internalBreakIter = ubrk_open(UBRK_CHARACTER, ucol_getLocale(result->collator, ULOC_VALID_LOCALE, status), text, textlength, status);
if (breakiter) {
ubrk_setText(breakiter, text, textlength, status);
}
@ -2650,6 +2650,9 @@ U_CAPI void U_EXPORT2 usearch_close(UStringSearch *strsrch)
if (strsrch->ownCollator && strsrch->collator) {
ucol_close((UCollator *)strsrch->collator);
}
if (strsrch->internalBreakIter) {
ubrk_close(strsrch->internalBreakIter);
}
uprv_free(strsrch->search);
uprv_free(strsrch);
}
@ -2832,7 +2835,7 @@ U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
ubrk_setText(strsrch->search->breakIter, text,
textlength, status);
}
ubrk_setText(strsrch->search->_breakIter_, text, textlength, status);
ubrk_setText(strsrch->search->internalBreakIter, text, textlength, status);
#endif
}
}
@ -2866,8 +2869,8 @@ U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
strsrch->strength = ucol_getStrength(collator);
strsrch->ceMask = getMask(strsrch->strength);
#if !UCONFIG_NO_BREAK_ITERATION
ubrk_close(strsrch->search->_breakIter_);
strsrch->search->_breakIter_ = ubrk_open(UBRK_CHARACTER, ucol_getLocale(collator, ULOC_VALID_LOCALE, status),
ubrk_close(strsrch->search->internalBreakIter);
strsrch->search->internalBreakIter = ubrk_open(UBRK_CHARACTER, ucol_getLocale(collator, ULOC_VALID_LOCALE, status),
strsrch->search->text, strsrch->search->textLength, status);
#endif
// if status is a failure, ucol_getAttribute returns UCOL_DEFAULT

View File

@ -26,7 +26,7 @@ struct USearch {
int32_t textLength; // exact length
UBool isOverlap;
UBool isCanonicalMatch;
UBreakIterator *_breakIter_; //internal character breakiterator
UBreakIterator *internalBreakIter; //internal character breakiterator
UBreakIterator *breakIter;
// value USEARCH_DONE is the default value
// if we are not at the start of the text or the end of the text,