sc/source/filter/excel/namebuff.cxx | 17 ++++++++--------- sc/source/filter/inc/namebuff.hxx | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-)
New commits: commit d4ec1c76b03c393dde62bd3913618147f9ddeea6 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Nov 20 10:22:00 2017 +0000 ofz#4321 Direct-leak Change-Id: I0ce2da99f34082e4e090753e3a4aa8fcc4420a5d Reviewed-on: https://gerrit.libreoffice.org/44955 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx index dbaa6b9257cd..efc575804106 100644 --- a/sc/source/filter/excel/namebuff.cxx +++ b/sc/source/filter/excel/namebuff.cxx @@ -47,7 +47,10 @@ sal_uInt32 StringHashEntry::MakeHashCode( const OUString& r ) return n; } -SharedFormulaBuffer::SharedFormulaBuffer( RootData* pRD ) : ExcRoot(pRD) {} +SharedFormulaBuffer::SharedFormulaBuffer(RootData* pRD) + : ExcRoot(pRD) +{ +} SharedFormulaBuffer::~SharedFormulaBuffer() { @@ -56,18 +59,14 @@ SharedFormulaBuffer::~SharedFormulaBuffer() void SharedFormulaBuffer::Clear() { - TokenArraysType::iterator it = maTokenArrays.begin(), itEnd = maTokenArrays.end(); - for (; it != itEnd; ++it) - delete it->second; - maTokenArrays.clear(); } void SharedFormulaBuffer::Store( const ScAddress& rPos, const ScTokenArray& rArray ) { - ScTokenArray* pCode = rArray.Clone(); - pCode->GenHash(); - maTokenArrays.emplace(rPos, pCode); + std::unique_ptr<ScTokenArray> xCode(rArray.Clone()); + xCode->GenHash(); + maTokenArrays.emplace(rPos, std::move(xCode)); } const ScTokenArray* SharedFormulaBuffer::Find( const ScAddress& rRefPos ) const @@ -76,7 +75,7 @@ const ScTokenArray* SharedFormulaBuffer::Find( const ScAddress& rRefPos ) const if (it == maTokenArrays.end()) return nullptr; - return it->second; + return it->second.get(); } sal_Int16 ExtSheetBuffer::Add( const OUString& rFPAN, const OUString& rTN, const bool bSWB ) diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx index 9daa50767fb9..a37b1fc7090f 100644 --- a/sc/source/filter/inc/namebuff.hxx +++ b/sc/source/filter/inc/namebuff.hxx @@ -63,7 +63,7 @@ inline bool StringHashEntry::operator ==( const StringHashEntry& r ) const */ class SharedFormulaBuffer : public ExcRoot { - typedef std::unordered_map<ScAddress, ScTokenArray*, ScAddressHashFunctor> TokenArraysType; + typedef std::unordered_map<ScAddress, std::unique_ptr<ScTokenArray>, ScAddressHashFunctor> TokenArraysType; TokenArraysType maTokenArrays; public:
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits