mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-17 02:37:25 +00:00
ICU-770 fix memory leaks
X-SVN-Rev: 6855
This commit is contained in:
parent
7a3107367d
commit
0d924e09c2
2 changed files with 22 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "unicode/titletrn.h"
|
||||
#include "unicode/uniset.h"
|
||||
#include "mutex.h"
|
||||
#include "ucln_in.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -77,6 +78,7 @@ void TitlecaseTransliterator::handleTransliterate(
|
|||
UErrorCode ec = U_ZERO_ERROR;
|
||||
SKIP = new UnicodeSet(UnicodeString("[\\u00AD \\u2019 \\' [:Mn:] [:Me:] [:Cf:]]", ""), ec);
|
||||
CASED = new UnicodeSet(UnicodeString("[[:Lu:] [:Ll:] [:Lt:]]", ""), ec);
|
||||
ucln_i18n_registerCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,5 +121,15 @@ void TitlecaseTransliterator::handleTransliterate(
|
|||
offsets.start = start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static memory cleanup function.
|
||||
*/
|
||||
void TitlecaseTransliterator::cleanup() {
|
||||
if (SKIP != NULL) {
|
||||
delete SKIP; SKIP = NULL;
|
||||
delete CASED; CASED = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
|
|
@ -1051,7 +1051,7 @@ Transliterator* Transliterator::parseID(const UnicodeString& ID,
|
|||
int32_t revSetStart, revSetLimit, dummy;
|
||||
if (!parseIDBounds(ID, revStart+1, TRUE, revLimit,
|
||||
revSetStart, revSetLimit, dummy, revFilter)) {
|
||||
delete filter;
|
||||
delete fwdFilter;
|
||||
delete revFilter;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1061,11 +1061,13 @@ Transliterator* Transliterator::parseID(const UnicodeString& ID,
|
|||
idLimit = revLimit;
|
||||
setStart = revSetStart;
|
||||
setLimit = revSetLimit;
|
||||
delete filter;
|
||||
delete fwdFilter;
|
||||
fwdFilter = NULL;
|
||||
filter = revFilter;
|
||||
} else {
|
||||
idLimit = revStart;
|
||||
delete revFilter;
|
||||
revFilter = NULL;
|
||||
}
|
||||
// assert(revLimit < ID.length() && ID.charAt(revLimit) == ')');
|
||||
limit = revLimit+1;
|
||||
|
@ -1205,6 +1207,10 @@ Transliterator* Transliterator::parseID(const UnicodeString& ID,
|
|||
// with [abc].
|
||||
t->adoptFilter(UnicodeFilterLogic::createAdoptingAnd(filter, t->orphanFilter()));
|
||||
}
|
||||
|
||||
else {
|
||||
delete filter;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the ID. This is normally just a substring of the input
|
||||
|
@ -1315,6 +1321,7 @@ UBool Transliterator::parseIDBounds(const UnicodeString& ID,
|
|||
filter->applyPattern(ID, ppos, 0, status);
|
||||
if (U_FAILURE(status)) {
|
||||
delete filter;
|
||||
filter = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
setLimit = ppos.getIndex();
|
||||
|
@ -1615,6 +1622,7 @@ U_NAMESPACE_END
|
|||
* user, because RBTs hold pointers to common data objects.
|
||||
*/
|
||||
U_CFUNC UBool transliterator_cleanup(void) {
|
||||
TitlecaseTransliterator::cleanup();
|
||||
delete registry;
|
||||
registry = 0;
|
||||
umtx_destroy(®istryMutex);
|
||||
|
|
Loading…
Add table
Reference in a new issue