diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-14 10:53:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-15 06:58:18 +0100 |
commit | 7883a5d1640f007ab05817540164043aa098b0dd (patch) | |
tree | 8c4e9aa195d82f6f7fbcbbeddeae19f16e0ec994 | |
parent | 2e0763633719f9f2a009956ace3e30d79d236ff9 (diff) |
use unique_ptr in WW8Style
Change-Id: I01b7b42d626a29b0702cc2aa51d0fdeb75282740
Reviewed-on: https://gerrit.libreoffice.org/66320
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 4 |
2 files changed, 9 insertions, 10 deletions
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; } }; |