diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-01 10:23:22 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-05 07:30:15 +0100 |
commit | 4eca66541bbe77767f29138f6d0265229d61173d (patch) | |
tree | 5dce6f3177f25f6603b5fe9b993c4a5bb6f4e445 /lotuswordpro | |
parent | 4516546b9efeeaa7cffe608fca8b544230aee3f1 (diff) |
loplugin:useuniqueptr in HuffmanTreeNode
Change-Id: I30655c5ad44c93968ec39938ced9854105a831dd
Reviewed-on: https://gerrit.libreoffice.org/50716
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/explode.cxx | 18 | ||||
-rw-r--r-- | lotuswordpro/source/filter/explode.hxx | 5 |
2 files changed, 7 insertions, 16 deletions
diff --git a/lotuswordpro/source/filter/explode.cxx b/lotuswordpro/source/filter/explode.cxx index 7f60a9dfa737..497252d1d67a 100644 --- a/lotuswordpro/source/filter/explode.cxx +++ b/lotuswordpro/source/filter/explode.cxx @@ -459,16 +459,6 @@ HuffmanTreeNode::HuffmanTreeNode(sal_uInt32 nValue ) } HuffmanTreeNode::~HuffmanTreeNode() { - if (left) - { - delete left; - left = nullptr; - } - if (right) - { - delete right; - right = nullptr; - } } HuffmanTreeNode * HuffmanTreeNode::InsertNode(sal_uInt32 nValue, const sal_Char * pInCode) @@ -485,9 +475,9 @@ HuffmanTreeNode * HuffmanTreeNode::InsertNode(sal_uInt32 nValue, const sal_Char pParent = InsertNode(0xffffffff, aCode.c_str()); } if (cLast == '0') - pParent->left = pNew; + pParent->left.reset(pNew); else // (cChar == '1') - pParent->right = pNew; + pParent->right.reset(pNew); return pNew; } @@ -502,11 +492,11 @@ HuffmanTreeNode * HuffmanTreeNode::QueryNode(const sal_Char * pCode) sal_Char cChar= pCode[i]; if (cChar == '0') { - pNode = pNode->left; + pNode = pNode->left.get(); } else // (cChar == '1') { - pNode = pNode->right; + pNode = pNode->right.get(); } } return pNode; diff --git a/lotuswordpro/source/filter/explode.hxx b/lotuswordpro/source/filter/explode.hxx index 013bb6bc881c..1b8cc587811c 100644 --- a/lotuswordpro/source/filter/explode.hxx +++ b/lotuswordpro/source/filter/explode.hxx @@ -57,14 +57,15 @@ #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_EXPLODE_HXX #include <sal/types.h> +#include <memory> class SvStream; class HuffmanTreeNode { public: - HuffmanTreeNode * left; - HuffmanTreeNode * right; + std::unique_ptr<HuffmanTreeNode> left; + std::unique_ptr<HuffmanTreeNode> right; sal_uInt32 value; explicit HuffmanTreeNode(sal_uInt32 value = 0xffffffff) ; |