diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-21 14:01:24 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-21 14:01:24 +0100 |
commit | eab26882e1e2215b85d4bfc1cefb219719e4a428 (patch) | |
tree | fcf67e92dc38d7e67d5bfc160d1507a8c239e88f /src/libutil | |
parent | 9be4e9c559238b5bdd2cf6ca89725306ab52b70b (diff) | |
download | rspamd-eab26882e1e2215b85d4bfc1cefb219719e4a428.tar.gz rspamd-eab26882e1e2215b85d4bfc1cefb219719e4a428.zip |
[Minor] Use unique ptr
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/cxx/utf8_util.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libutil/cxx/utf8_util.cxx b/src/libutil/cxx/utf8_util.cxx index 4be7e9c58..8bb709abf 100644 --- a/src/libutil/cxx/utf8_util.cxx +++ b/src/libutil/cxx/utf8_util.cxx @@ -165,9 +165,9 @@ rspamd_utf8_transliterate(const gchar *start, gsize len, gsize *target_len) { UErrorCode uc_err = U_ZERO_ERROR; - static const icu::Transliterator *transliterator = nullptr; + static std::unique_ptr<icu::Transliterator> transliterator; - if (transliterator == nullptr) { + if (!transliterator) { UParseError parse_err; static const auto rules = icu::UnicodeString{":: Any-Latin;" ":: [:Nonspacing Mark:] Remove;" @@ -179,9 +179,10 @@ rspamd_utf8_transliterate(const gchar *start, gsize len, gsize *target_len) ":: NULL;" "[:Space Separator:] > ' '" }; - transliterator = icu::Transliterator::createFromRules("RspamdTranslit", rules, UTRANS_FORWARD, parse_err, uc_err); + transliterator = std::unique_ptr<icu::Transliterator>( + icu::Transliterator::createFromRules("RspamdTranslit", rules, UTRANS_FORWARD, parse_err, uc_err)); - if (U_FAILURE(uc_err) || transliterator == nullptr) { + if (U_FAILURE(uc_err) || !transliterator) { auto context = icu::UnicodeString(parse_err.postContext, sizeof(parse_err.preContext) / sizeof(UChar)); g_error ("fatal error: cannot init libicu transliteration engine: %s, line: %d, offset: %d", u_errorName(uc_err), parse_err.line, parse_err.offset); |