From 8003f8694ac7c4bc117f7ce692339534d37681f0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 Oct 2018 14:25:42 +0200 Subject: loplugin:useuniqueptr in oneToOneMappingWithFlag Change-Id: I729d6640c105ca43fdd2e3e702f6f62876db75e5 Reviewed-on: https://gerrit.libreoffice.org/62647 Tested-by: Jenkins Reviewed-by: Noel Grandin --- i18nutil/source/utility/oneToOneMapping.cxx | 10 +--------- 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 #include +#include namespace i18nutil { @@ -80,7 +81,7 @@ public: private: UnicodePairWithFlag const *mpTableWF; UnicodePairFlag mnFlag; - UnicodePairWithFlag const **mpIndex[256]; + std::unique_ptr mpIndex[256]; bool mbHasIndex; }; -- cgit