[Libreoffice-commits] core.git: helpcompiler/inc helpcompiler/source hwpfilter/source i18npool/inc i18npool/source idl/inc idl/source io/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 17 08:35:04 UTC 2017


 helpcompiler/inc/HelpLinker.hxx                                       |    3 -
 helpcompiler/source/HelpLinker.cxx                                    |    5 -
 hwpfilter/source/hbox.cxx                                             |    1 
 hwpfilter/source/hbox.h                                               |   29 ++++------
 hwpfilter/source/hwpread.cxx                                          |    4 -
 i18npool/inc/calendar_gregorian.hxx                                   |    4 +
 i18npool/inc/defaultnumberingprovider.hxx                             |    4 +
 i18npool/inc/indexentrysupplier_common.hxx                            |    5 +
 i18npool/inc/indexentrysupplier_default.hxx                           |    6 +-
 i18npool/source/calendar/calendar_gregorian.cxx                       |    3 -
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |    3 -
 i18npool/source/indexentry/indexentrysupplier_common.cxx              |    3 -
 i18npool/source/indexentry/indexentrysupplier_default.cxx             |    6 --
 i18npool/source/localedata/localedata.cxx                             |   10 ---
 i18npool/source/search/levdis.hxx                                     |   12 ++--
 idl/inc/lex.hxx                                                       |    4 -
 idl/source/cmptools/lex.cxx                                           |    1 
 io/source/stm/omark.cxx                                               |   12 +---
 io/source/stm/opipe.cxx                                               |   21 ++-----
 19 files changed, 58 insertions(+), 78 deletions(-)

New commits:
commit 7a60e90ef05c84923f83882efc01c33fef1ed305
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 16 14:15:13 2017 +0200

    new loplugin: useuniqueptr: helpcompiler..io
    
    Change-Id: I6b394163c144e6b5540cb160abb613d56fe327de
    Reviewed-on: https://gerrit.libreoffice.org/33165
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/helpcompiler/inc/HelpLinker.hxx b/helpcompiler/inc/HelpLinker.hxx
index 8be1b4a..7fce510 100644
--- a/helpcompiler/inc/HelpLinker.hxx
+++ b/helpcompiler/inc/HelpLinker.hxx
@@ -61,7 +61,6 @@ public:
     {}
     ~HelpLinker()
     {
-        delete m_pIndexerPreProcessor;
     }
 
 private:
@@ -82,7 +81,7 @@ private:
     std::string extensionDestination;
     bool bExtensionMode;
     fs::path indexDirParentName;
-    IndexerPreProcessor* m_pIndexerPreProcessor;
+    std::unique_ptr<IndexerPreProcessor> m_pIndexerPreProcessor;
     bool m_bUseLangRoot;
     bool m_bCreateIndex;
     void initIndexerPreProcessor();
diff --git a/helpcompiler/source/HelpLinker.cxx b/helpcompiler/source/HelpLinker.cxx
index 3c992be..1af6a58 100644
--- a/helpcompiler/source/HelpLinker.cxx
+++ b/helpcompiler/source/HelpLinker.cxx
@@ -266,9 +266,8 @@ void HelpLinker::addBookmark( FILE* pFile_DBHelp, std::string thishid,
 
 void HelpLinker::initIndexerPreProcessor()
 {
-    delete m_pIndexerPreProcessor;
-    m_pIndexerPreProcessor = new IndexerPreProcessor( indexDirParentName,
-         idxCaptionStylesheet, idxContentStylesheet );
+    m_pIndexerPreProcessor.reset( new IndexerPreProcessor( indexDirParentName,
+         idxCaptionStylesheet, idxContentStylesheet ) );
 }
 
 /**
diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index da9e206..c3587f4 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -85,7 +85,6 @@ SkipData::SkipData(hchar hch)
 
 SkipData::~SkipData()
 {
-    delete[]data_block;
 }
 
 
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index 3832c76..8d039ae 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -23,6 +23,7 @@
 #include <sal/config.h>
 
 #include <list>
+#include <memory>
 
 #include <sal/types.h>
 
@@ -73,7 +74,7 @@ struct SkipData: public HBox
 {
     uint data_block_len;
     hchar dummy;
-    char  *data_block;
+    std::unique_ptr<char[]> data_block;
 
     explicit SkipData(hchar);
     virtual ~SkipData() override;
@@ -385,27 +386,26 @@ struct TxtBox: public FBox
 
 struct Columns
 {
-     int *data;
+     std::unique_ptr<int[]> data;
      size_t nCount;
      size_t nTotal;
      Columns(){
           nCount = 0;
           nTotal = INIT_SIZE;
-          data = new int[nTotal];
+          data.reset(new int[nTotal]);
      }
-     ~Columns(){ delete[] data; }
+     ~Columns() {}
 
      void AddColumnsSize(){
-          int *tmp = data;
           if (nTotal + ADD_AMOUNT < nTotal) // overflow
           {
               throw ::std::bad_alloc();
           }
-          data = new int[nTotal + ADD_AMOUNT];
+          int* tmp = new int[nTotal + ADD_AMOUNT];
           for (size_t i = 0 ; i < nTotal ; i++)
-                data[i] = tmp[i];
+                tmp[i] = data[i];
           nTotal += ADD_AMOUNT;
-          delete[] tmp;
+          data.reset(tmp);
      }
 
      void insert(int pos){
@@ -446,27 +446,26 @@ struct Columns
 
 struct Rows
 {
-     int *data;
+     std::unique_ptr<int[]> data;
      size_t nCount;
      size_t nTotal;
      Rows(){
           nCount = 0;
           nTotal = INIT_SIZE;
-          data = new int[nTotal];
+          data.reset( new int[nTotal] );
      }
-     ~Rows(){ delete[] data; }
+     ~Rows() {}
 
      void AddRowsSize(){
-          int *tmp = data;
           if (nTotal + ADD_AMOUNT < nTotal) // overflow
           {
               throw ::std::bad_alloc();
           }
-          data = new int[nTotal + ADD_AMOUNT];
+          int* tmp = new int[nTotal + ADD_AMOUNT];
           for (size_t i = 0 ; i < nTotal ; i++)
-                data[i] = tmp[i];
+                tmp[i] = data[i];
           nTotal += ADD_AMOUNT;
-          delete[] tmp;
+          data.reset(tmp);
      }
 
      void insert(int pos){
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 377c13e..5616258 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -52,9 +52,9 @@ bool SkipData::Read(HWPFile & hwpf)
         return hwpf.SetState(HWP_InvalidFileFormat);
      }
 
-    data_block = new char[data_block_len];
+    data_block.reset(new char[data_block_len]);
 
-    return hwpf.Read1b(data_block, data_block_len);
+    return hwpf.Read1b(data_block.get(), data_block_len);
 }
 
 
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index 98f48bc..a83969c 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -25,6 +25,8 @@
 #include <unicode/calendar.h>
 #include <rtl/ref.hxx>
 
+#include <memory>
+
 
 //  class Calendar_gregorian
 
@@ -97,7 +99,7 @@ public:
 
 protected:
     const Era *eraArray;
-    icu::Calendar *body;
+    std::unique_ptr<icu::Calendar> body;
     rtl::Reference<NativeNumberSupplierService> mxNatNum;
     const sal_Char* cCalendar;
     css::lang::Locale aLocale;
diff --git a/i18npool/inc/defaultnumberingprovider.hxx b/i18npool/inc/defaultnumberingprovider.hxx
index 5140a55..200dc0b 100644
--- a/i18npool/inc/defaultnumberingprovider.hxx
+++ b/i18npool/inc/defaultnumberingprovider.hxx
@@ -29,6 +29,8 @@
 
 #include <transliterationImpl.hxx>
 
+#include <memory>
+
 namespace com { namespace sun { namespace star { namespace i18n {
 
 class DefaultNumberingProvider : public cppu::WeakImplHelper
@@ -83,7 +85,7 @@ public:
 private:
     css::uno::Reference < css::uno::XComponentContext > m_xContext;
     css::uno::Reference < css::container::XHierarchicalNameAccess > xHierarchicalNameAccess;
-    TransliterationImpl* translit;
+    std::unique_ptr<TransliterationImpl> translit;
     OUString SAL_CALL makeNumberingIdentifier( sal_Int16 index )
         throw(css::uno::RuntimeException, std::exception);
     bool SAL_CALL isScriptFlagEnabled(const OUString& aName )
diff --git a/i18npool/inc/indexentrysupplier_common.hxx b/i18npool/inc/indexentrysupplier_common.hxx
index cf3120b..f25731d 100644
--- a/i18npool/inc/indexentrysupplier_common.hxx
+++ b/i18npool/inc/indexentrysupplier_common.hxx
@@ -25,6 +25,8 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <collatorImpl.hxx>
 
+#include <memory>
+
 namespace com { namespace sun { namespace star { namespace i18n {
 
 
@@ -90,7 +92,8 @@ public:
 protected:
     const sal_Char *   implementationName;
     bool               usePhonetic;
-    CollatorImpl*      collator;
+    std::unique_ptr<CollatorImpl>
+                       collator;
     css::lang::Locale  aLocale;
     OUString           aAlgorithm;
 
diff --git a/i18npool/inc/indexentrysupplier_default.hxx b/i18npool/inc/indexentrysupplier_default.hxx
index 49b3558..901dc1d 100644
--- a/i18npool/inc/indexentrysupplier_default.hxx
+++ b/i18npool/inc/indexentrysupplier_default.hxx
@@ -21,6 +21,8 @@
 
 #include <indexentrysupplier_common.hxx>
 
+#include <memory>
+
 namespace com { namespace sun { namespace star { namespace i18n {
 
 class Index;
@@ -53,7 +55,7 @@ public:
         throw (css::uno::RuntimeException, std::exception) override;
 
 private:
-    Index *index;
+    std::unique_ptr<Index> index;
 };
 
 struct IndexKey {
@@ -97,7 +99,7 @@ public:
     sal_Int16 mkeys[MAX_KEYS];
     sal_Int16 mkey_count;
     OUString skipping_chars;
-    CollatorImpl *collator;
+    std::unique_ptr<CollatorImpl> collator;
     sal_Int16 compare(sal_Unicode c1, sal_Unicode c2);
 };
 
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index c7ff413..e70666e 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -168,14 +168,13 @@ Calendar_gregorian::init(const Era *_eraArray)
     icu::Locale aIcuLocale( "", nullptr, nullptr, "calendar=gregorian");
 
     UErrorCode status;
-    body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
+    body.reset( icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR) );
     if (!body || !U_SUCCESS(status)) throw ERROR;
     eraArray=_eraArray;
 }
 
 Calendar_gregorian::~Calendar_gregorian()
 {
-    delete body;
 }
 
 Calendar_hanja::Calendar_hanja()
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 0990651..f44e408 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -273,7 +273,6 @@ DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XComponent
 
 DefaultNumberingProvider::~DefaultNumberingProvider()
 {
-    delete translit;
 }
 
 Sequence< Reference<container::XIndexAccess> >
@@ -647,7 +646,7 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
                     OUString transliteration;
                     getPropertyByName(aProperties, "Transliteration", true) >>= transliteration;
                     if ( !translit )
-                        translit = new TransliterationImpl(m_xContext);
+                        translit.reset( new TransliterationImpl(m_xContext) );
                     translit->loadModuleByImplName(transliteration, aLocale);
                     result += translit->transliterateString2String(tmp, 0, tmp.getLength());
                } catch (Exception& ) {
diff --git a/i18npool/source/indexentry/indexentrysupplier_common.cxx b/i18npool/source/indexentry/indexentrysupplier_common.cxx
index fafb304..ee5d0d1 100644
--- a/i18npool/source/indexentry/indexentrysupplier_common.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier_common.cxx
@@ -30,13 +30,12 @@ namespace com { namespace sun { namespace star { namespace i18n {
 IndexEntrySupplier_Common::IndexEntrySupplier_Common(const Reference < uno::XComponentContext >& rxContext)
 {
     implementationName = "com.sun.star.i18n.IndexEntrySupplier_Common";
-    collator = new CollatorImpl(rxContext);
+    collator.reset( new CollatorImpl(rxContext) );
     usePhonetic = false;
 }
 
 IndexEntrySupplier_Common::~IndexEntrySupplier_Common()
 {
-    delete collator;
 }
 
 Sequence < lang::Locale > SAL_CALL IndexEntrySupplier_Common::getLocaleList() throw (RuntimeException, std::exception)
diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx
index 2c902cf..8762e9e 100644
--- a/i18npool/source/indexentry/indexentrysupplier_default.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx
@@ -32,12 +32,11 @@ IndexEntrySupplier_Unicode::IndexEntrySupplier_Unicode(
     IndexEntrySupplier_Common(rxContext)
 {
     implementationName = "com.sun.star.i18n.IndexEntrySupplier_Unicode";
-    index = new Index(rxContext);
+    index.reset( new Index(rxContext) );
 }
 
 IndexEntrySupplier_Unicode::~IndexEntrySupplier_Unicode()
 {
-    delete index;
 }
 
 sal_Bool SAL_CALL IndexEntrySupplier_Unicode::loadAlgorithm( const lang::Locale& rLocale,
@@ -111,13 +110,12 @@ Index::Index(const css::uno::Reference < css::uno::XComponentContext >& rxContex
     : table_count(0)
     , key_count(0)
     , mkey_count(0)
+    , collator( new CollatorImpl(rxContext) )
 {
-    collator = new CollatorImpl(rxContext);
 }
 
 Index::~Index()
 {
-    delete collator;
 }
 
 sal_Int16 Index::compare(sal_Unicode c1, sal_Unicode c2)
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 3a0c0ee2..f3499f9 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -1323,11 +1323,10 @@ class OutlineNumbering : public cppu::WeakImplHelper < container::XIndexAccess >
 {
     // OutlineNumbering helper class
 
-    const OutlineNumberingLevel_Impl* m_pOutlineLevels;
+    std::unique_ptr<const OutlineNumberingLevel_Impl[]> m_pOutlineLevels;
     sal_Int16                         m_nCount;
 public:
     OutlineNumbering(const OutlineNumberingLevel_Impl* pOutlineLevels, int nLevels);
-    virtual ~OutlineNumbering() override;
 
     //XIndexAccess
     virtual sal_Int32 SAL_CALL getCount(  ) throw(RuntimeException, std::exception) override;
@@ -1498,11 +1497,6 @@ OutlineNumbering::OutlineNumbering(const OutlineNumberingLevel_Impl* pOutlnLevel
 {
 }
 
-OutlineNumbering::~OutlineNumbering()
-{
-    delete [] m_pOutlineLevels;
-}
-
 sal_Int32 OutlineNumbering::getCount(  ) throw(RuntimeException, std::exception)
 {
     return m_nCount;
@@ -1513,7 +1507,7 @@ Any OutlineNumbering::getByIndex( sal_Int32 nIndex )
 {
     if(nIndex < 0 || nIndex >= m_nCount)
         throw IndexOutOfBoundsException();
-    const OutlineNumberingLevel_Impl* pTemp = m_pOutlineLevels;
+    const OutlineNumberingLevel_Impl* pTemp = m_pOutlineLevels.get();
     pTemp += nIndex;
     Any aRet;
 
diff --git a/i18npool/source/search/levdis.hxx b/i18npool/source/search/levdis.hxx
index cd12628..4d834bd 100644
--- a/i18npool/source/search/levdis.hxx
+++ b/i18npool/source/search/levdis.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_I18NPOOL_SOURCE_SEARCH_LEVDIS_HXX
 
 #include <rtl/ustring.hxx>
+#include <memory>
 
 // Sensible default values for a user interface could be:
 //  LEVDISDEFAULT_XOTHER    2
@@ -115,19 +116,18 @@ public:
 
 class WLevDisDistanceMem
 {
-    int*    p;
+    std::unique_ptr<int[]> p;
 public:
     explicit WLevDisDistanceMem( size_t s )
-        : p(nullptr)
     {
         NewMem(s);
     }
-    ~WLevDisDistanceMem()           { delete [] p; }
-    int* GetPtr() const             { return p; }
+    ~WLevDisDistanceMem()           {}
+    int* GetPtr() const             { return p.get(); }
     int* NewMem( size_t s )
     {
-        delete [] p;
-        return (p = new int[ s<3 ? 3 : s ]);
+        p.reset(new int[ s<3 ? 3 : s ]);
+        return p.get();
     }
 };
 
diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx
index 102a088..40e7fe1 100644
--- a/idl/inc/lex.hxx
+++ b/idl/inc/lex.hxx
@@ -106,8 +106,8 @@ class SvTokenStream
     OString         aStrFalse;
     sal_uLong       nMaxPos;
 
-    SvFileStream *  pInStream;
-    OUString        aFileName;
+    std::unique_ptr<SvFileStream>          pInStream;
+    OUString                               aFileName;
     std::vector<std::unique_ptr<SvToken> > aTokList;
     std::vector<std::unique_ptr<SvToken> >::iterator pCurToken;
 
diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx
index 1626b20..58ccf2b 100644
--- a/idl/source/cmptools/lex.cxx
+++ b/idl/source/cmptools/lex.cxx
@@ -91,7 +91,6 @@ SvTokenStream::SvTokenStream( const OUString & rFileName )
 
 SvTokenStream::~SvTokenStream()
 {
-    delete pInStream;
 }
 
 void SvTokenStream::FillTokenList()
diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index 9cb1fa4..31d0760 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -19,6 +19,7 @@
 
 
 #include <map>
+#include <memory>
 #include <vector>
 
 #include <com/sun/star/io/XMarkableStream.hpp>
@@ -75,7 +76,6 @@ class OMarkableOutputStream :
 {
 public:
     OMarkableOutputStream(  );
-    virtual ~OMarkableOutputStream() override;
 
 public: // XOutputStream
     virtual void SAL_CALL writeBytes(const Sequence< sal_Int8 >& aData)
@@ -138,7 +138,7 @@ private:
     Reference< XOutputStream >  m_output;
     bool m_bValidStream;
 
-    MemRingBuffer *m_pBuffer;
+    std::unique_ptr<MemRingBuffer> m_pBuffer;
     map<sal_Int32,sal_Int32,less< sal_Int32 > > m_mapMarks;
     sal_Int32 m_nCurrentPos;
     sal_Int32 m_nCurrentMark;
@@ -148,18 +148,12 @@ private:
 
 OMarkableOutputStream::OMarkableOutputStream( )
     : m_bValidStream(false)
+    , m_pBuffer( new MemRingBuffer )
     , m_nCurrentPos(0)
     , m_nCurrentMark(0)
 {
-    m_pBuffer = new MemRingBuffer;
-}
-
-OMarkableOutputStream::~OMarkableOutputStream()
-{
-    delete m_pBuffer;
 }
 
-
 // XOutputStream
 void OMarkableOutputStream::writeBytes(const Sequence< sal_Int8 >& aData)
     throw ( NotConnectedException,
diff --git a/io/source/stm/opipe.cxx b/io/source/stm/opipe.cxx
index be0905a..4d70e67 100644
--- a/io/source/stm/opipe.cxx
+++ b/io/source/stm/opipe.cxx
@@ -34,6 +34,7 @@
 #include <osl/mutex.hxx>
 
 #include <limits>
+#include <memory>
 #include <string.h>
 
 using namespace ::osl;
@@ -55,7 +56,6 @@ class OPipeImpl :
 {
 public:
     OPipeImpl( );
-    virtual ~OPipeImpl() override;
 
 public: // XInputStream
     virtual sal_Int32 SAL_CALL readBytes(Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
@@ -118,24 +118,18 @@ private:
 
     osl::Condition m_conditionBytesAvail;
     Mutex          m_mutexAccess;
-    MemFIFO       *m_pFIFO;
+    std::unique_ptr<MemFIFO> m_pFIFO;
 };
 
 
 OPipeImpl::OPipeImpl()
+    : m_nBytesToSkip(0 )
+    , m_bOutputStreamClosed(false )
+    , m_bInputStreamClosed( false )
+    , m_pFIFO( new MemFIFO )
 {
-    m_nBytesToSkip  = 0;
-
-    m_bOutputStreamClosed   = false;
-    m_bInputStreamClosed    = false;
-
-    m_pFIFO = new MemFIFO;
 }
 
-OPipeImpl::~OPipeImpl()
-{
-    delete m_pFIFO;
-}
 
 
 sal_Int32 OPipeImpl::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
@@ -261,8 +255,7 @@ void OPipeImpl::closeInput()
 
     m_bInputStreamClosed = true;
 
-    delete m_pFIFO;
-    m_pFIFO = nullptr;
+    m_pFIFO.reset();
 
     // readBytes may throw an exception
     m_conditionBytesAvail.set();


More information about the Libreoffice-commits mailing list