[Libreoffice-commits] core.git: cppu/source idlc/inc idlc/source io/source ucbhelper/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jan 11 06:37:52 UTC 2018


 cppu/source/AffineBridge/AffineBridge.cxx                 |   13 +--
 cppu/source/helper/purpenv/helper_purpenv_Environment.cxx |    5 -
 cppu/source/typelib/typelib.cxx                           |   18 +----
 idlc/inc/astexpression.hxx                                |    6 +
 idlc/source/astexpression.cxx                             |    2 
 idlc/source/idlc.cxx                                      |    2 
 io/source/acceptor/acceptor.cxx                           |   20 ++----
 ucbhelper/source/provider/contenthelper.cxx               |   46 ++++----------
 ucbhelper/source/provider/resultset.cxx                   |   20 +-----
 9 files changed, 49 insertions(+), 83 deletions(-)

New commits:
commit b27fee9e0ebb445ce82baeade3b249807dca392b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 10 11:44:28 2018 +0200

    loplugin:useuniqueptr cppu,idlc,io,ucbhelper
    
    Change-Id: I6d8c24fabd52b39c66ce0b88b547df7ec85dad76
    Reviewed-on: https://gerrit.libreoffice.org/47725
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cppu/source/AffineBridge/AffineBridge.cxx b/cppu/source/AffineBridge/AffineBridge.cxx
index b63b8777a0dd..9926d56ca0ab 100644
--- a/cppu/source/AffineBridge/AffineBridge.cxx
+++ b/cppu/source/AffineBridge/AffineBridge.cxx
@@ -26,6 +26,7 @@
 #include <cppu/Enterable.hxx>
 #include <cppu/helper/purpenv/Environment.hxx>
 #include <cppu/helper/purpenv/Mapping.hxx>
+#include <memory>
 
 
 class InnerThread;
@@ -46,14 +47,14 @@ public:
 
     osl::Mutex            m_innerMutex;
     oslThreadIdentifier   m_innerThreadId;
-    InnerThread         * m_pInnerThread;
+    std::unique_ptr<InnerThread> m_pInnerThread;
     osl::Condition        m_innerCondition;
     sal_Int32             m_enterCount;
 
     osl::Mutex            m_outerMutex;
     oslThreadIdentifier   m_outerThreadId;
     osl::Condition        m_outerCondition;
-    OuterThread         * m_pOuterThread;
+    std::unique_ptr<OuterThread> m_pOuterThread;
 
     explicit  AffineBridge();
     virtual  ~AffineBridge() override;
@@ -149,12 +150,11 @@ AffineBridge::~AffineBridge()
         m_pInnerThread->join();
     }
 
-    delete m_pInnerThread;
+    m_pInnerThread.reset();
 
     if (m_pOuterThread)
     {
         m_pOuterThread->join();
-        delete m_pOuterThread;
     }
 }
 
@@ -238,7 +238,7 @@ void AffineBridge::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam)
 
     if (m_innerThreadId == 0) // no inner thread yet
     {
-        m_pInnerThread  = new InnerThread(this);
+        m_pInnerThread.reset(new InnerThread(this));
         m_pInnerThread->resume();
     }
 
@@ -275,10 +275,9 @@ void AffineBridge::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam)
             if (m_pOuterThread)
             {
                 m_pOuterThread->join();
-                delete m_pOuterThread;
             }
 
-            m_pOuterThread = new OuterThread(this);
+            m_pOuterThread.reset(new OuterThread(this));
         }
     }
 
diff --git a/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx b/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx
index 8d24442faa11..d1de047f4679 100644
--- a/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx
+++ b/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx
@@ -26,6 +26,7 @@
 
 #include <typelib/typedescription.h>
 #include <osl/interlck.h>
+#include <memory>
 
 extern "C" {
 typedef void EnvFun_P   (uno_Environment *);
@@ -95,7 +96,7 @@ public:
 protected:
     oslInterlockedCount    m_nRef;
     uno_Environment      * m_pEnv;
-    cppu::Enterable      * m_pEnterable;
+    std::unique_ptr<cppu::Enterable> m_pEnterable;
 
     EnvFun_P    * m_env_acquire;
     EnvFun_P    * m_env_release;
@@ -263,7 +264,7 @@ Base::~Base()
 
     m_pEnv->pReserved = nullptr;
 
-    delete m_pEnterable;
+    m_pEnterable.reset();
     m_pEnv->release(m_pEnv);
 }
 
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index a99746ef0600..1077761710d7 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -23,6 +23,7 @@
 #include <list>
 #include <set>
 #include <vector>
+#include <memory>
 
 #include <stdarg.h>
 #include <stdlib.h>
@@ -174,11 +175,11 @@ struct TypeDescriptor_Init_Impl
     // all type description references
     WeakMap_Impl *              pWeakMap;
     // all type description callbacks
-    CallbackSet_Impl *          pCallbacks;
+    std::unique_ptr<CallbackSet_Impl> pCallbacks;
     // A cache to hold descriptions
     TypeDescriptionList_Impl *  pCache;
     // The mutex to guard all type library accesses
-    Mutex *                     pMutex;
+    std::unique_ptr<Mutex>      pMutex;
 
     inline Mutex & getMutex();
 
@@ -217,7 +218,7 @@ inline Mutex & TypeDescriptor_Init_Impl::getMutex()
     {
         MutexGuard aGuard( Mutex::getGlobalMutex() );
         if( !pMutex )
-            pMutex = new Mutex();
+            pMutex.reset(new Mutex());
     }
     return * pMutex;
 }
@@ -318,14 +319,7 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
 #endif
 
     SAL_INFO_IF( pCallbacks && !pCallbacks->empty(), "cppu.typelib", "pCallbacks is not NULL or empty" );
-    delete pCallbacks;
-    pCallbacks = nullptr;
-
-    if( pMutex )
-    {
-        delete pMutex;
-        pMutex = nullptr;
-    }
+    pCallbacks.reset();
 };
 
 namespace { struct Init : public rtl::Static< TypeDescriptor_Init_Impl, Init > {}; }
@@ -338,7 +332,7 @@ extern "C" void SAL_CALL typelib_typedescription_registerCallback(
     TypeDescriptor_Init_Impl &rInit = Init::get();
 //      OslGuard aGuard( rInit.getMutex() );
     if( !rInit.pCallbacks )
-        rInit.pCallbacks = new CallbackSet_Impl;
+        rInit.pCallbacks.reset(new CallbackSet_Impl);
     rInit.pCallbacks->push_back( CallbackEntry( pContext, pCallback ) );
 }
 
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index 9dac7e79cc10..68f8c4e4a937 100644
--- a/idlc/inc/astexpression.hxx
+++ b/idlc/inc/astexpression.hxx
@@ -127,8 +127,10 @@ private:
     OString  m_fileName;     // fileName defined in
 
     ExprComb        m_combOperator;
-    AstExpression*  m_subExpr1;
-    AstExpression*  m_subExpr2;
+    std::unique_ptr<AstExpression>
+                    m_subExpr1;
+    std::unique_ptr<AstExpression>
+                    m_subExpr2;
     std::unique_ptr<AstExprValue>
                     m_exprValue;
     std::unique_ptr<OString>
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index f63663badbaa..b42e7e3188ca 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -123,8 +123,6 @@ AstExpression::AstExpression(OString* scopedName)
 
 AstExpression::~AstExpression()
 {
-    delete m_subExpr1;
-    delete m_subExpr2;
 }
 
 /*
diff --git a/idlc/source/idlc.cxx b/idlc/source/idlc.cxx
index 008e1aaa3e91..2e7467b8ac59 100644
--- a/idlc/source/idlc.cxx
+++ b/idlc/source/idlc.cxx
@@ -217,8 +217,6 @@ Idlc::Idlc(Options* pOptions)
 
 Idlc::~Idlc()
 {
-    delete m_pRoot;
-    delete m_pScopes;
 }
 
 void Idlc::init()
diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx
index e27b83acd290..c9449f6eb146 100644
--- a/io/source/acceptor/acceptor.cxx
+++ b/io/source/acceptor/acceptor.cxx
@@ -36,6 +36,7 @@
 
 #include <services.hxx>
 #include "acceptor.hxx"
+#include <memory>
 
 #define IMPLEMENTATION_NAME "com.sun.star.comp.io.Acceptor"
 #define SERVICE_NAME "com.sun.star.connection.Acceptor"
@@ -65,8 +66,8 @@ namespace io_acceptor
                 virtual sal_Bool              SAL_CALL supportsService(const OUString& ServiceName) override;
 
     private:
-        PipeAcceptor *m_pPipe;
-        SocketAcceptor *m_pSocket;
+        std::unique_ptr<PipeAcceptor> m_pPipe;
+        std::unique_ptr<SocketAcceptor> m_pSocket;
         Mutex m_mutex;
         OUString m_sLastDescription;
         bool m_bInAccept;
@@ -87,8 +88,7 @@ namespace io_acceptor
 
     OAcceptor::~OAcceptor()
     {
-        delete m_pPipe;
-        delete m_pSocket;
+        m_pPipe.reset();
     }
 
     struct BeingInAccept
@@ -138,7 +138,7 @@ namespace io_acceptor
                         aDesc.getParameter(
                             "name"));
 
-                    m_pPipe = new PipeAcceptor(aName, sConnectionDescription);
+                    m_pPipe.reset(new PipeAcceptor(aName, sConnectionDescription));
 
                     try
                     {
@@ -148,8 +148,7 @@ namespace io_acceptor
                     {
                         {
                             MutexGuard g( m_mutex );
-                            delete m_pPipe;
-                            m_pPipe = nullptr;
+                            m_pPipe.reset();
                         }
                         throw;
                     }
@@ -171,8 +170,8 @@ namespace io_acceptor
                         = aDesc.getParameter(
                             "tcpnodelay").toInt32() != 0;
 
-                    m_pSocket = new SocketAcceptor(
-                        aHost, nPort, bTcpNoDelay, sConnectionDescription);
+                    m_pSocket.reset(new SocketAcceptor(
+                        aHost, nPort, bTcpNoDelay, sConnectionDescription));
 
                     try
                     {
@@ -182,8 +181,7 @@ namespace io_acceptor
                     {
                         {
                             MutexGuard g( m_mutex );
-                            delete m_pSocket;
-                            m_pSocket = nullptr;
+                            m_pSocket.reset();
                         }
                         throw;
                     }
diff --git a/ucbhelper/source/provider/contenthelper.cxx b/ucbhelper/source/provider/contenthelper.cxx
index c6d08ec8afbd..f031df08a7a9 100644
--- a/ucbhelper/source/provider/contenthelper.cxx
+++ b/ucbhelper/source/provider/contenthelper.cxx
@@ -98,27 +98,11 @@ struct ContentImplHelper_Impl
 {
     rtl::Reference< ::ucbhelper::PropertySetInfo >      m_xPropSetInfo;
     rtl::Reference< ::ucbhelper::CommandProcessorInfo > m_xCommandsInfo;
-    cppu::OInterfaceContainerHelper*              m_pDisposeEventListeners;
-    cppu::OInterfaceContainerHelper*              m_pContentEventListeners;
-    cppu::OInterfaceContainerHelper*              m_pPropSetChangeListeners;
-    cppu::OInterfaceContainerHelper*              m_pCommandChangeListeners;
-    PropertyChangeListeners*                      m_pPropertyChangeListeners;
-
-    ContentImplHelper_Impl()
-    : m_pDisposeEventListeners( nullptr ),
-        m_pContentEventListeners( nullptr ),
-      m_pPropSetChangeListeners( nullptr ),
-        m_pCommandChangeListeners( nullptr ),
-      m_pPropertyChangeListeners( nullptr ) {}
-
-    ~ContentImplHelper_Impl()
-    {
-        delete m_pDisposeEventListeners;
-        delete m_pContentEventListeners;
-        delete m_pPropSetChangeListeners;
-        delete m_pCommandChangeListeners;
-        delete m_pPropertyChangeListeners;
-    }
+    std::unique_ptr<cppu::OInterfaceContainerHelper>    m_pDisposeEventListeners;
+    std::unique_ptr<cppu::OInterfaceContainerHelper>    m_pContentEventListeners;
+    std::unique_ptr<cppu::OInterfaceContainerHelper>    m_pPropSetChangeListeners;
+    std::unique_ptr<cppu::OInterfaceContainerHelper>    m_pCommandChangeListeners;
+    std::unique_ptr<PropertyChangeListeners>            m_pPropertyChangeListeners;
 };
 
 } // namespace ucbhelper_impl
@@ -252,8 +236,8 @@ void SAL_CALL ContentImplHelper::addEventListener(
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_pImpl->m_pDisposeEventListeners )
-        m_pImpl->m_pDisposeEventListeners
-            = new cppu::OInterfaceContainerHelper( m_aMutex );
+        m_pImpl->m_pDisposeEventListeners.reset(
+            new cppu::OInterfaceContainerHelper( m_aMutex ));
 
     m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
 }
@@ -282,8 +266,8 @@ void SAL_CALL ContentImplHelper::addContentEventListener(
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_pImpl->m_pContentEventListeners )
-        m_pImpl->m_pContentEventListeners
-            = new cppu::OInterfaceContainerHelper( m_aMutex );
+        m_pImpl->m_pContentEventListeners.reset(
+            new cppu::OInterfaceContainerHelper( m_aMutex ));
 
     m_pImpl->m_pContentEventListeners->addInterface( Listener );
 }
@@ -315,8 +299,8 @@ void SAL_CALL ContentImplHelper::addPropertiesChangeListener(
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_pImpl->m_pPropertyChangeListeners )
-        m_pImpl->m_pPropertyChangeListeners
-            = new PropertyChangeListeners( m_aMutex );
+        m_pImpl->m_pPropertyChangeListeners.reset(
+            new PropertyChangeListeners( m_aMutex ));
 
     sal_Int32 nCount = PropertyNames.getLength();
     if ( !nCount )
@@ -377,8 +361,8 @@ void SAL_CALL ContentImplHelper::addCommandInfoChangeListener(
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_pImpl->m_pCommandChangeListeners )
-        m_pImpl->m_pCommandChangeListeners
-            = new cppu::OInterfaceContainerHelper( m_aMutex );
+        m_pImpl->m_pCommandChangeListeners.reset(
+            new cppu::OInterfaceContainerHelper( m_aMutex ));
 
     m_pImpl->m_pCommandChangeListeners->addInterface( Listener );
 }
@@ -583,8 +567,8 @@ void SAL_CALL ContentImplHelper::addPropertySetInfoChangeListener(
     osl::MutexGuard aGuard( m_aMutex );
 
     if ( !m_pImpl->m_pPropSetChangeListeners )
-        m_pImpl->m_pPropSetChangeListeners
-            = new cppu::OInterfaceContainerHelper( m_aMutex );
+        m_pImpl->m_pPropSetChangeListeners.reset(
+            new cppu::OInterfaceContainerHelper( m_aMutex ));
 
     m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
 }
diff --git a/ucbhelper/source/provider/resultset.cxx b/ucbhelper/source/provider/resultset.cxx
index 780a2dc0fcdb..3c160e6d390f 100644
--- a/ucbhelper/source/provider/resultset.cxx
+++ b/ucbhelper/source/provider/resultset.cxx
@@ -143,8 +143,8 @@ struct ResultSet_Impl
     uno::Sequence< beans::Property >                m_aProperties;
     rtl::Reference< ResultSetDataSupplier >         m_xDataSupplier;
     osl::Mutex                          m_aMutex;
-    cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
-    PropertyChangeListeners*            m_pPropertyChangeListeners;
+    std::unique_ptr<cppu::OInterfaceContainerHelper> m_pDisposeEventListeners;
+    std::unique_ptr<PropertyChangeListeners>        m_pPropertyChangeListeners;
     sal_Int32                           m_nPos;
     bool                            m_bWasNull;
     bool                            m_bAfterLast;
@@ -154,7 +154,6 @@ struct ResultSet_Impl
         const uno::Sequence< beans::Property >& rProperties,
         const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
         const uno::Reference< css::ucb::XCommandEnvironment >& rxEnv );
-    inline ~ResultSet_Impl();
 };
 
 inline ResultSet_Impl::ResultSet_Impl(
@@ -175,13 +174,6 @@ inline ResultSet_Impl::ResultSet_Impl(
 }
 
 
-inline ResultSet_Impl::~ResultSet_Impl()
-{
-    delete m_pDisposeEventListeners;
-    delete m_pPropertyChangeListeners;
-}
-
-
 // ResultSet Implementation.
 
 
@@ -313,8 +305,8 @@ void SAL_CALL ResultSet::addEventListener(
     osl::MutexGuard aGuard( m_pImpl->m_aMutex );
 
     if ( !m_pImpl->m_pDisposeEventListeners )
-        m_pImpl->m_pDisposeEventListeners =
-            new cppu::OInterfaceContainerHelper( m_pImpl->m_aMutex );
+        m_pImpl->m_pDisposeEventListeners.reset(
+            new cppu::OInterfaceContainerHelper( m_pImpl->m_aMutex ));
 
     m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
 }
@@ -1314,8 +1306,8 @@ void SAL_CALL ResultSet::addPropertyChangeListener(
         throw beans::UnknownPropertyException();
 
     if ( !m_pImpl->m_pPropertyChangeListeners )
-        m_pImpl->m_pPropertyChangeListeners
-            = new PropertyChangeListeners( m_pImpl->m_aMutex );
+        m_pImpl->m_pPropertyChangeListeners.reset(
+             new PropertyChangeListeners( m_pImpl->m_aMutex ));
 
     m_pImpl->m_pPropertyChangeListeners->addInterface(
                                                 aPropertyName, xListener );


More information about the Libreoffice-commits mailing list