sw/source/filter/ww8/ww8par.cxx | 16 ++++++++-------- sw/source/filter/ww8/ww8par5.cxx | 5 ++--- sw/source/filter/ww8/ww8scan.cxx | 15 +++++++-------- sw/source/filter/ww8/ww8scan.hxx | 4 ++-- 4 files changed, 19 insertions(+), 21 deletions(-)
New commits: commit 7883a5d1640f007ab05817540164043aa098b0dd Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jan 14 10:53:08 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 15 06:58:18 2019 +0100 use unique_ptr in WW8Style Change-Id: I01b7b42d626a29b0702cc2aa51d0fdeb75282740 Reviewed-on: https://gerrit.libreoffice.org/66320 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 5df59ec42ccd..976fe8971f27 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -6875,9 +6875,9 @@ WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara) // so it has no empty slot, we should allocate memory and a pointer should // reference to STD (perhaps filled with 0). If the slot is empty, // it will return a null pointer. -WW8_STD* WW8Style::Read1STDFixed(sal_uInt16& rSkip) +std::unique_ptr<WW8_STD> WW8Style::Read1STDFixed(sal_uInt16& rSkip) { - WW8_STD* pStd = nullptr; + std::unique_ptr<WW8_STD> pStd; sal_uInt16 cbStd(0); m_rStream.ReadUInt16(cbStd); // read length @@ -6888,8 +6888,8 @@ WW8_STD* WW8Style::Read1STDFixed(sal_uInt16& rSkip) // Fixed part completely available // read fixed part of STD - pStd = new WW8_STD; - memset( pStd, 0, sizeof( *pStd ) ); + pStd.reset(new WW8_STD); + memset( pStd.get(), 0, sizeof( *pStd ) ); do { @@ -6936,8 +6936,7 @@ WW8_STD* WW8Style::Read1STDFixed(sal_uInt16& rSkip) if (!m_rStream.good() || !nRead) { - delete pStd; - pStd = nullptr; // report error with NULL + pStd.reset(); // report error with NULL } rSkip = cbStd - m_cbSTDBaseInFile; @@ -6951,12 +6950,12 @@ WW8_STD* WW8Style::Read1STDFixed(sal_uInt16& rSkip) return pStd; } -WW8_STD* WW8Style::Read1Style(sal_uInt16& rSkip, OUString* pString) +std::unique_ptr<WW8_STD> WW8Style::Read1Style(sal_uInt16& rSkip, OUString* pString) { // Attention: MacWord-Documents have their Stylenames // always in ANSI, even if eStructCharSet == CHARSET_MAC !! - WW8_STD* pStd = Read1STDFixed(rSkip); // read STD + std::unique_ptr<WW8_STD> pStd = Read1STDFixed(rSkip); // read STD // string desired? if( pString ) diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 9a9dd905cabd..5aa3dc596798 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -1571,8 +1571,8 @@ protected: public: WW8Style( SvStream& rSt, WW8Fib& rFibPara ); - WW8_STD* Read1STDFixed(sal_uInt16& rSkip); - WW8_STD* Read1Style(sal_uInt16& rSkip, OUString* pString); + std::unique_ptr<WW8_STD> Read1STDFixed(sal_uInt16& rSkip); + std::unique_ptr<WW8_STD> Read1Style(sal_uInt16& rSkip, OUString* pString); sal_uInt16 GetCount() const { return m_cstd; } }; commit 2e0763633719f9f2a009956ace3e30d79d236ff9 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jan 14 10:49:23 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 15 06:58:07 2019 +0100 use unique_ptr in sw Change-Id: I02026ffd808fa4939666c791c476cd0c0632cde3 Reviewed-on: https://gerrit.libreoffice.org/66319 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index f938fd78d117..18642cc06621 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -5771,10 +5771,10 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss) m_pStrm->Seek(0); size_t nUnencryptedHdr = (8 == m_xWwFib->m_nVersion) ? 0x44 : 0x34; - sal_uInt8 *pIn = new sal_uInt8[nUnencryptedHdr]; - nUnencryptedHdr = m_pStrm->ReadBytes(pIn, nUnencryptedHdr); - aDecryptMain.WriteBytes(pIn, nUnencryptedHdr); - delete [] pIn; + std::unique_ptr<sal_uInt8[]> pIn(new sal_uInt8[nUnencryptedHdr]); + nUnencryptedHdr = m_pStrm->ReadBytes(pIn.get(), nUnencryptedHdr); + aDecryptMain.WriteBytes(pIn.get(), nUnencryptedHdr); + pIn.reset(); DecryptXOR(aCtx, *m_pStrm, aDecryptMain); @@ -5838,14 +5838,14 @@ ErrCode SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss) m_pStrm->Seek(0); std::size_t nUnencryptedHdr = 0x44; - sal_uInt8 *pIn = new sal_uInt8[nUnencryptedHdr]; - nUnencryptedHdr = m_pStrm->ReadBytes(pIn, nUnencryptedHdr); + std::unique_ptr<sal_uInt8[]> pIn(new sal_uInt8[nUnencryptedHdr]); + nUnencryptedHdr = m_pStrm->ReadBytes(pIn.get(), nUnencryptedHdr); DecryptRC4(*xCtx, *m_pStrm, aDecryptMain); aDecryptMain.Seek(0); - aDecryptMain.WriteBytes(pIn, nUnencryptedHdr); - delete [] pIn; + aDecryptMain.WriteBytes(pIn.get(), nUnencryptedHdr); + pIn.reset(); pTempTable = MakeTemp(aDecryptTable); DecryptRC4(*xCtx, *m_pTableStream, aDecryptTable); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 4ff133dca23a..ef2bc17f0986 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -3270,7 +3270,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) // In an ideal world we could handle the tab stop between the number and // the entry correctly, but I currently have no clue how to obtain // the tab stop position. It is _not_ set at the paragraph style. - SwForm* pForm = nullptr; + std::unique_ptr<SwForm> pForm; for (SwWW8StyInf & rSI : m_vColl) { if (rSI.IsOutlineNumbered()) @@ -3282,7 +3282,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) ++nStyleLevel; if ( !pForm ) - pForm = new SwForm( pBase->GetTOXForm() ); + pForm.reset(new SwForm( pBase->GetTOXForm() )); SwFormTokens aPattern = pForm->GetPattern(nStyleLevel); SwFormTokens::iterator aIt = @@ -3302,7 +3302,6 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) if ( pForm ) { pBase->SetTOXForm( *pForm ); - delete pForm; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits