[Libreoffice-commits] core.git: include/sot sd/source sot/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jul 12 06:27:55 UTC 2018


 include/sot/storage.hxx        |    2 +-
 sd/source/filter/eppt/eppt.cxx |    4 ++--
 sot/source/sdstor/storage.cxx  |    8 +++-----
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit acde273ea8b105ed5cc7adec98110b822a1b4490
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jul 11 17:14:09 2018 +0200

    return SvMemoryStream by std::unique_ptr
    
    Change-Id: I60a41111e76d72a7384cbb15f2d2a73c95af8c2d
    Reviewed-on: https://gerrit.libreoffice.org/57280
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sot/storage.hxx b/include/sot/storage.hxx
index b8cbe947557a..83437604d164 100644
--- a/include/sot/storage.hxx
+++ b/include/sot/storage.hxx
@@ -85,7 +85,7 @@ public:
                         SotStorage( bool bUCBStorage, SvStream & rStm );
                         SotStorage( SvStream * pStm, bool bDelete );
 
-    SvMemoryStream *    CreateMemoryStream();
+    std::unique_ptr<SvMemoryStream> CreateMemoryStream();
 
     static bool         IsStorageFile( const OUString & rFileName );
     static bool         IsStorageFile( SvStream* pStream );
diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx
index 2e5818701dda..395fb50b2677 100644
--- a/sd/source/filter/eppt/eppt.cxx
+++ b/sd/source/filter/eppt/eppt.cxx
@@ -1261,7 +1261,7 @@ void PPTWriter::ImplWriteOLE( )
     for ( auto it = maExOleObj.begin(); it != maExOleObj.end(); ++it )
     {
         PPTExOleObjEntry* pPtr = it->get();
-        SvMemoryStream* pStrm = nullptr;
+        std::unique_ptr<SvMemoryStream> pStrm;
         pPtr->nOfsB = mpStrm->Tell();
         switch ( pPtr->eType )
         {
@@ -1324,7 +1324,7 @@ void PPTWriter::ImplWriteOLE( )
             aZCodec.BeginCompression();
             aZCodec.Compress( *pStrm, *mpStrm );
             aZCodec.EndCompression();
-            delete pStrm;
+            pStrm.reset();
             mpPptEscherEx->EndAtom( EPP_ExOleObjStg, 0, 1 );
         }
     }
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 3848fd941585..85279dec46cc 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -456,10 +456,9 @@ SotStorage::~SotStorage()
         delete m_pStorStm;
 }
 
-SvMemoryStream * SotStorage::CreateMemoryStream()
+std::unique_ptr<SvMemoryStream> SotStorage::CreateMemoryStream()
 {
-    SvMemoryStream * pStm = nullptr;
-    pStm = new SvMemoryStream( 0x8000, 0x8000 );
+    std::unique_ptr<SvMemoryStream> pStm(new SvMemoryStream( 0x8000, 0x8000 ));
     tools::SvRef<SotStorage> aStg = new SotStorage( *pStm );
     if( CopyTo( aStg.get() ) )
     {
@@ -468,8 +467,7 @@ SvMemoryStream * SotStorage::CreateMemoryStream()
     else
     {
         aStg.clear(); // release storage beforehand
-        delete pStm;
-        pStm = nullptr;
+        pStm.reset();
     }
     return pStm;
 }


More information about the Libreoffice-commits mailing list