diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-29 14:25:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-31 07:31:11 +0100 |
commit | 8003f8694ac7c4bc117f7ce692339534d37681f0 (patch) | |
tree | d4d3aa1aa32ebe3ead11b7df2bfcbb280cb4faff | |
parent | b3c449b74f64cad8b3c0403acbe283c9a588b690 (diff) |
loplugin:useuniqueptr in oneToOneMappingWithFlag
Change-Id: I729d6640c105ca43fdd2e3e702f6f62876db75e5
Reviewed-on: https://gerrit.libreoffice.org/62647
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | i18nutil/source/utility/oneToOneMapping.cxx | 10 | ||||
-rw-r--r-- | include/i18nutil/oneToOneMapping.hxx | 3 |
2 files changed, 3 insertions, 10 deletions
diff --git a/i18nutil/source/utility/oneToOneMapping.cxx b/i18nutil/source/utility/oneToOneMapping.cxx index 8e71ea01e418..0fdea0599004 100644 --- a/i18nutil/source/utility/oneToOneMapping.cxx +++ b/i18nutil/source/utility/oneToOneMapping.cxx @@ -67,11 +67,6 @@ oneToOneMappingWithFlag::oneToOneMappingWithFlag( UnicodePairWithFlag const *rpT oneToOneMappingWithFlag::~oneToOneMappingWithFlag() { - if( mbHasIndex ) - { - for (UnicodePairWithFlag const ** i : mpIndex) - delete [] i; - } } void oneToOneMappingWithFlag::makeIndex() @@ -80,9 +75,6 @@ void oneToOneMappingWithFlag::makeIndex() { int current = -1; - for (UnicodePairWithFlag const **& i : mpIndex) - i = nullptr; - for( size_t k = 0; k < mnSize; k++ ) { const int high = (mpTableWF[k].first >> 8) & 0xFF; @@ -90,7 +82,7 @@ void oneToOneMappingWithFlag::makeIndex() if( high != current ) { current = high; - mpIndex[high] = new UnicodePairWithFlag const *[256]; + mpIndex[high].reset(new UnicodePairWithFlag const *[256]); for (int j = 0; j < 256; ++j) mpIndex[high][j] = nullptr; diff --git a/include/i18nutil/oneToOneMapping.hxx b/include/i18nutil/oneToOneMapping.hxx index c3e49f574f44..80550d957158 100644 --- a/include/i18nutil/oneToOneMapping.hxx +++ b/include/i18nutil/oneToOneMapping.hxx @@ -21,6 +21,7 @@ #include <rtl/ustring.hxx> #include <i18nutil/i18nutildllapi.h> +#include <memory> namespace i18nutil { @@ -80,7 +81,7 @@ public: private: UnicodePairWithFlag const *mpTableWF; UnicodePairFlag mnFlag; - UnicodePairWithFlag const **mpIndex[256]; + std::unique_ptr<UnicodePairWithFlag const *[]> mpIndex[256]; bool mbHasIndex; }; |