[Libreoffice-commits] core.git: 2 commits - l10ntools/source sdext/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 5 07:29:20 UTC 2018


 l10ntools/source/helpmerge.cxx                   |    5 +---
 l10ntools/source/treemerge.cxx                   |   11 ++++------
 sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx |   24 +++++++++++------------
 3 files changed, 19 insertions(+), 21 deletions(-)

New commits:
commit fe0ae0efe894ad2b313a5278f3c5ede03747bf4e
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 4 11:53:06 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 5 09:29:09 2018 +0200

    loplugin:useuniqueptr in PngHelper::createPng
    
    Change-Id: I55ec28c88a89eab927a46ec666c3698065b151d2
    Reviewed-on: https://gerrit.libreoffice.org/59995
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
index 44f30c0bab28..4d9e3bb46b61 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
@@ -245,11 +245,11 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
     Guchar *p, *pm;
     GfxRGB rgb;
     GfxGray alpha;
-    ImageStream* imgStr =
+    std::unique_ptr<ImageStream> imgStr(
         new ImageStream(str,
                         width,
                         colorMap->getNumPixelComps(),
-                        colorMap->getBits());
+                        colorMap->getBits()));
     imgStr->reset();
 
     // create scan line data buffer
@@ -281,11 +281,11 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
     // the other, too. Hence the two passes are imperative !
 
     // initialize mask stream
-    ImageStream* imgStrMask =
+    std::unique_ptr<ImageStream> imgStrMask(
         new ImageStream(maskStr,
                         maskWidth,
                         maskColorMap->getNumPixelComps(),
-                        maskColorMap->getBits());
+                        maskColorMap->getBits()));
 
     imgStrMask->reset();
     for( int y = 0; y < maskHeight; ++y )
@@ -302,8 +302,8 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
         }
     }
 
-    delete imgStr;
-    delete imgStrMask;
+    imgStr.reset();
+    imgStrMask.reset();
 
     // begind IDAT chunk for scanline data
     size_t nIdx = startChunk( "IDAT", o_rOutputBuf );
@@ -330,11 +330,11 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
     // initialize stream
     Guchar *p;
     GfxRGB rgb;
-    ImageStream* imgStr =
+    std::unique_ptr<ImageStream> imgStr(
         new ImageStream(str,
                         width,
                         colorMap->getNumPixelComps(),
-                        colorMap->getBits());
+                        colorMap->getBits()));
     imgStr->reset();
 
     // create scan line data buffer
@@ -366,8 +366,8 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
     // the other, too. Hence the two passes are imperative !
 
     // initialize mask stream
-    ImageStream* imgStrMask =
-        new ImageStream(maskStr, maskWidth, 1, 1);
+    std::unique_ptr<ImageStream> imgStrMask(
+        new ImageStream(maskStr, maskWidth, 1, 1));
 
     imgStrMask->reset();
     for( int y = 0; y < maskHeight; ++y )
@@ -386,8 +386,8 @@ void PngHelper::createPng( OutputBuffer& o_rOutputBuf,
         }
     }
 
-    delete imgStr;
-    delete imgStrMask;
+    imgStr.reset();
+    imgStrMask.reset();
 
     // begind IDAT chunk for scanline data
     size_t nIdx = startChunk( "IDAT", o_rOutputBuf );
commit 1fd4927817df1134749ec7b69620c49b0089e00b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 4 09:52:25 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 5 09:28:55 2018 +0200

    loplugin:useuniqueptr in l10ntools
    
    Change-Id: I8aaab2f3055bd0856926803ee7f71107b7cb1851
    Reviewed-on: https://gerrit.libreoffice.org/59994
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 0a2e3c3dfd52..663b4a945a1a 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -150,14 +150,13 @@ bool HelpParser::Merge( const OString &rDestinationFile,
 
     //TODO: explicit BOM handling?
 
-    XMLFile* xmlfile = aParser.Execute( sHelpFile, new XMLFile( OString('0') ) );
+    std::unique_ptr<XMLFile> xmlfile(aParser.Execute( sHelpFile, new XMLFile( OString('0') ) ));
     if (!xmlfile)
     {
         SAL_WARN("l10ntools", "could not parse " << sHelpFile);
         return false;
     }
-    MergeSingleFile( xmlfile , pMergeDataFile , rLanguage , rDestinationFile );
-    delete xmlfile;
+    MergeSingleFile( xmlfile.get() , pMergeDataFile , rLanguage , rDestinationFile );
     return true;
 }
 
diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx
index 791c1aebf52a..c874603edfa2 100644
--- a/l10ntools/source/treemerge.cxx
+++ b/l10ntools/source/treemerge.cxx
@@ -253,11 +253,11 @@ void TreeParser::Merge(
     assert( m_bIsInitialized );
 
     const xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource );
-    MergeDataFile* pMergeDataFile = nullptr;
+    std::unique_ptr<MergeDataFile> pMergeDataFile;
     if( m_sLang != "qtz" && m_sLang != "en-US" )
     {
-        pMergeDataFile = new MergeDataFile(
-            rMergeSrc, static_cast<OString>( m_pSource->name ), false, false );
+        pMergeDataFile.reset(new MergeDataFile(
+            rMergeSrc, static_cast<OString>( m_pSource->name ), false, false ));
         const std::vector<OString> vLanguages = pMergeDataFile->GetLanguages();
         if( vLanguages.size()>=1 && vLanguages[0] != m_sLang )
         {
@@ -266,15 +266,14 @@ void TreeParser::Merge(
                     " Mergedata file: ")
                 << m_sLang << " - "
                 << vLanguages[0] << std::endl;
-            delete pMergeDataFile;
             return;
         }
     }
     lcl_MergeLevel(
         m_pSource, pRootNode, reinterpret_cast<const xmlChar *>("help_section"),
-        pMergeDataFile, m_sLang, rXhpRoot );
+        pMergeDataFile.get(), m_sLang, rXhpRoot );
 
-    delete pMergeDataFile;
+    pMergeDataFile.reset();
     xmlSaveFile( rDestinationFile.getStr(), m_pSource );
     xmlFreeDoc( m_pSource );
     xmlCleanupParser();


More information about the Libreoffice-commits mailing list