diff options
-rw-r--r-- | include/toolkit/awt/vclxfont.hxx | 3 | ||||
-rw-r--r-- | include/tools/simplerm.hxx | 4 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 3 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.hxx | 5 | ||||
-rw-r--r-- | sot/source/sdstor/stgole.cxx | 3 | ||||
-rw-r--r-- | sot/source/sdstor/stgole.hxx | 2 | ||||
-rw-r--r-- | sot/source/sdstor/stgstrms.cxx | 7 | ||||
-rw-r--r-- | sot/source/sdstor/stgstrms.hxx | 2 | ||||
-rw-r--r-- | stoc/source/corereflection/base.hxx | 10 | ||||
-rw-r--r-- | stoc/source/corereflection/crcomp.cxx | 3 | ||||
-rw-r--r-- | stoc/source/corereflection/crenum.cxx | 3 | ||||
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 9 | ||||
-rw-r--r-- | toolkit/source/awt/vclxfont.cxx | 6 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 10 | ||||
-rw-r--r-- | tools/source/rc/resmgr.cxx | 11 |
15 files changed, 38 insertions, 43 deletions
diff --git a/include/toolkit/awt/vclxfont.hxx b/include/toolkit/awt/vclxfont.hxx index d9550e742e82..ebc09e7190c7 100644 --- a/include/toolkit/awt/vclxfont.hxx +++ b/include/toolkit/awt/vclxfont.hxx @@ -42,7 +42,8 @@ private: ::osl::Mutex maMutex; css::uno::Reference< css::awt::XDevice> mxDevice; vcl::Font maFont; - FontMetric* mpFontMetric; + std::unique_ptr<FontMetric> + mpFontMetric; protected: bool ImplAssertValidFontMetric(); diff --git a/include/tools/simplerm.hxx b/include/tools/simplerm.hxx index 28d008ed7e59..79e267ad07f2 100644 --- a/include/tools/simplerm.hxx +++ b/include/tools/simplerm.hxx @@ -27,13 +27,15 @@ #include <tools/resid.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/toolsdllapi.h> +#include <memory> class InternalResMgr; class TOOLS_DLLPUBLIC SimpleResMgr final { osl::Mutex m_aAccessSafety; - InternalResMgr* m_pResImpl; + std::unique_ptr<InternalResMgr> + m_pResImpl; public: /** creates a new SimpleResManager diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index 2ee2c28ede39..409e4729a874 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -44,12 +44,11 @@ StgPage::StgPage( short nSize, sal_Int32 nPage ) OSL_ENSURE( mnSize >= 512, "Unexpected page size is provided!" ); // We will write this data to a permanent file later // best to clear if first. - memset( mpData, 0, mnSize ); + memset( mpData.get(), 0, mnSize ); } StgPage::~StgPage() { - delete [] mpData; } rtl::Reference< StgPage > StgPage::Create( short nData, sal_Int32 nPage ) diff --git a/sot/source/sdstor/stgcache.hxx b/sot/source/sdstor/stgcache.hxx index 5a1ec3809607..59649023cc0c 100644 --- a/sot/source/sdstor/stgcache.hxx +++ b/sot/source/sdstor/stgcache.hxx @@ -96,7 +96,8 @@ public: class StgPage : public salhelper::SimpleReferenceObject { const sal_Int32 mnPage; // page index - sal_uInt8* mpData; // nSize bytes + std::unique_ptr<sal_uInt8> + mpData; // nSize bytes short mnSize; // size of this page StgPage( short nData, sal_Int32 nPage ); virtual ~StgPage() override; @@ -106,7 +107,7 @@ public: static rtl::Reference< StgPage > Create( short nData, sal_Int32 nPage ); sal_Int32 GetPage() { return mnPage; } - void* GetData() { return mpData; } + void* GetData() { return mpData.get(); } short GetSize() { return mnSize; } public: diff --git a/sot/source/sdstor/stgole.cxx b/sot/source/sdstor/stgole.cxx index 9adfcac5fbd4..acec45204eac 100644 --- a/sot/source/sdstor/stgole.cxx +++ b/sot/source/sdstor/stgole.cxx @@ -36,7 +36,7 @@ StgInternalStream::StgInternalStream( BaseStorage& rStg, const OUString& rName, StreamMode nMode = bWr ? StreamMode::WRITE | StreamMode::SHARE_DENYALL : StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE; - m_pStrm = rStg.OpenStream( rName, nMode ); + m_pStrm.reset( rStg.OpenStream( rName, nMode ) ); // set the error code right here in the stream SetError( rStg.GetError() ); @@ -45,7 +45,6 @@ StgInternalStream::StgInternalStream( BaseStorage& rStg, const OUString& rName, StgInternalStream::~StgInternalStream() { - delete m_pStrm; } std::size_t StgInternalStream::GetData(void* pData, std::size_t nSize) diff --git a/sot/source/sdstor/stgole.hxx b/sot/source/sdstor/stgole.hxx index cfe09b18ba63..0bdf50397ff6 100644 --- a/sot/source/sdstor/stgole.hxx +++ b/sot/source/sdstor/stgole.hxx @@ -27,7 +27,7 @@ class StgInternalStream : public SvStream { - BaseStorageStream* m_pStrm; + std::unique_ptr<BaseStorageStream> m_pStrm; virtual std::size_t GetData(void* pData, std::size_t nSize) override; virtual std::size_t PutData(const void* pData, std::size_t nSize) override; virtual sal_uInt64 SeekPos( sal_uInt64 nPos ) override; diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 7063a4ce99d3..3503421c341c 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -330,7 +330,6 @@ StgStrm::StgStrm( StgIo& r ) : m_rIo( r ) StgStrm::~StgStrm() { - delete m_pFat; } // Attach the stream to the given entry. @@ -558,7 +557,7 @@ bool StgStrm::SetSize( sal_Int32 nBytes ) StgFATStrm::StgFATStrm( StgIo& r ) : StgStrm( r ) { - m_pFat = new StgFAT( *this, true ); + m_pFat.reset( new StgFAT( *this, true ) ); m_nSize = m_rIo.m_aHdr.GetFATSize() * m_nPageSize; } @@ -821,7 +820,7 @@ StgDataStrm::StgDataStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r ) void StgDataStrm::Init( sal_Int32 nBgn, sal_Int32 nLen ) { if ( m_rIo.m_pFAT ) - m_pFat = new StgFAT( *m_rIo.m_pFAT, true ); + m_pFat.reset( new StgFAT( *m_rIo.m_pFAT, true ) ); OSL_ENSURE( m_pFat, "The pointer should not be empty!" ); @@ -1027,7 +1026,7 @@ StgSmallStrm::StgSmallStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r ) void StgSmallStrm::Init( sal_Int32 nBgn, sal_Int32 nLen ) { if ( m_rIo.m_pDataFAT ) - m_pFat = new StgFAT( *m_rIo.m_pDataFAT, false ); + m_pFat.reset( new StgFAT( *m_rIo.m_pDataFAT, false ) ); m_pData = m_rIo.m_pDataStrm; OSL_ENSURE( m_pFat && m_pData, "The pointers should not be empty!" ); diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx index e523e98a924f..9b9c41c30254 100644 --- a/sot/source/sdstor/stgstrms.hxx +++ b/sot/source/sdstor/stgstrms.hxx @@ -62,7 +62,7 @@ public: class StgStrm { // base class for all streams protected: StgIo& m_rIo; // I/O system - StgFAT* m_pFat; // FAT stream for allocations + std::unique_ptr<StgFAT> m_pFat; // FAT stream for allocations StgDirEntry* m_pEntry; // dir entry (for ownership) sal_Int32 m_nStart; // 1st data page sal_Int32 m_nSize; // stream size in bytes diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx index b92da9a59866..15a95309c8b0 100644 --- a/stoc/source/corereflection/base.hxx +++ b/stoc/source/corereflection/base.hxx @@ -42,6 +42,7 @@ #include <algorithm> #endif #include <unordered_map> +#include <memory> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -229,9 +230,10 @@ public: class CompoundIdlClassImpl : public IdlClassImpl { - css::uno::Reference< css::reflection::XIdlClass > _xSuperClass; - - css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > * _pFields; + css::uno::Reference< css::reflection::XIdlClass > + _xSuperClass; + std::unique_ptr< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > > + _pFields; OUString2Field _aName2Field; public: @@ -294,7 +296,7 @@ public: class EnumIdlClassImpl : public IdlClassImpl { - css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > * _pFields; + std::unique_ptr< css::uno::Sequence< css::uno::Reference< css::reflection::XIdlField > > > _pFields; OUString2Field _aName2Field; public: diff --git a/stoc/source/corereflection/crcomp.cxx b/stoc/source/corereflection/crcomp.cxx index 6e76911b2fff..3596e220a3c4 100644 --- a/stoc/source/corereflection/crcomp.cxx +++ b/stoc/source/corereflection/crcomp.cxx @@ -277,7 +277,6 @@ void IdlCompFieldImpl::set( Any & rObj, const Any & rValue ) CompoundIdlClassImpl::~CompoundIdlClassImpl() { - delete _pFields; } @@ -374,7 +373,7 @@ Sequence< Reference< XIdlField > > CompoundIdlClassImpl::getFields() } } - _pFields = pFields; + _pFields.reset( pFields ); } return *_pFields; } diff --git a/stoc/source/corereflection/crenum.cxx b/stoc/source/corereflection/crenum.cxx index 74c7a565bdca..594897049fef 100644 --- a/stoc/source/corereflection/crenum.cxx +++ b/stoc/source/corereflection/crenum.cxx @@ -165,7 +165,6 @@ void IdlEnumFieldImpl::set( Any &, const Any & ) EnumIdlClassImpl::~EnumIdlClassImpl() { - delete _pFields; } // IdlClassImpl modifications @@ -203,7 +202,7 @@ Sequence< Reference< XIdlField > > EnumIdlClassImpl::getFields() getReflection(), aName, IdlClassImpl::getTypeDescr(), getTypeDescr()->pEnumValues[nFields] ); } - _pFields = pFields; + _pFields.reset( pFields ); } } return *_pFields; diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 4a4ac6bcc170..da3b8c961ead 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -23,6 +23,7 @@ #include <cstddef> #include <limits> #include <map> +#include <memory> #include <set> #include <o3tl/any.hxx> @@ -209,7 +210,7 @@ class IntrospectionAccessStatic_Impl: public salhelper::SimpleReferenceObject bool mbUnoTunnel; // Original handles of FastPropertySets - sal_Int32* mpOrgPropertyHandleArray; + std::unique_ptr<sal_Int32[]> mpOrgPropertyHandleArray; // MethodSequence, that accepts all methods std::vector< Reference<XIdlMethod> > maAllMethodSeq; @@ -230,10 +231,6 @@ class IntrospectionAccessStatic_Impl: public salhelper::SimpleReferenceObject public: explicit IntrospectionAccessStatic_Impl( Reference< XIdlReflection > const & xCoreReflection_ ); - virtual ~IntrospectionAccessStatic_Impl() override - { - delete[] mpOrgPropertyHandleArray; - } sal_Int32 getPropertyIndex( const OUString& aPropertyName ) const; sal_Int32 getMethodIndex( const OUString& aMethodName ) const; @@ -1779,7 +1776,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( // For a FastPropertySet we must remember the original handles if( bFast ) - pAccess->mpOrgPropertyHandleArray = new sal_Int32[ nLen ]; + pAccess->mpOrgPropertyHandleArray.reset( new sal_Int32[ nLen ] ); for( i = 0 ; i < nLen ; i++ ) { diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index aa42cf64272e..1df5b56ee233 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -40,15 +40,13 @@ VCLXFont::VCLXFont() VCLXFont::~VCLXFont() { - delete mpFontMetric; } void VCLXFont::Init( css::awt::XDevice& rxDev, const vcl::Font& rFont ) { mxDevice = &rxDev; - delete mpFontMetric; - mpFontMetric = nullptr; + mpFontMetric.reset(); maFont = rFont; } @@ -62,7 +60,7 @@ bool VCLXFont::ImplAssertValidFontMetric() { vcl::Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); - mpFontMetric = new FontMetric( pOutDev->GetFontMetric() ); + mpFontMetric.reset( new FontMetric( pOutDev->GetFontMetric() ) ); pOutDev->SetFont( aOldFont ); } } diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 00852e085968..9d862e26c0ec 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -118,11 +118,12 @@ public: bool mbSynthesizingVCLEvent : 1; bool mbWithDefaultProps : 1; - sal_uLong mnListenerLockLevel; + sal_uLong mnListenerLockLevel; sal_Int16 mnWritingMode; sal_Int16 mnContextWritingMode; - UnoPropertyArrayHelper* mpPropHelper; + std::unique_ptr<UnoPropertyArrayHelper> + mpPropHelper; css::uno::Reference< css::awt::XPointer > mxPointer; @@ -224,7 +225,6 @@ VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, bool _bWithDefaultProps VCLXWindowImpl::~VCLXWindowImpl() { - delete mpPropHelper; } @@ -2551,9 +2551,9 @@ VCLXWindow::GetPropHelper() { std::vector< sal_uInt16 > aIDs; GetPropertyIds( aIDs ); - mpImpl->mpPropHelper = new UnoPropertyArrayHelper( aIDs ); + mpImpl->mpPropHelper.reset( new UnoPropertyArrayHelper( aIDs ) ); } - return mpImpl->mpPropHelper; + return mpImpl->mpPropHelper.get(); } css::uno::Sequence< css::beans::Property > SAL_CALL diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx index 4670528609b7..d810bd2a9cc4 100644 --- a/tools/source/rc/resmgr.cxx +++ b/tools/source/rc/resmgr.cxx @@ -94,7 +94,6 @@ class InternalResMgr const OUString& aPrefix, const OUString& aResName, const LanguageTag& rLocale ); - ~InternalResMgr(); bool Create(); bool IsGlobalAvailable( RESOURCE_TYPE nRT, sal_uInt32 nId ) const; @@ -102,6 +101,7 @@ class InternalResMgr void **pResHandle ); public: static void FreeGlobalRes( void const *, void * ); + ~InternalResMgr(); }; class ResMgrContainer @@ -1414,13 +1414,12 @@ SimpleResMgr::SimpleResMgr( const sal_Char* pPrefixName, if( aLocale.isSystemLocale() ) aLocale = ResMgrContainer::get().getDefLocale(); - m_pResImpl = ResMgrContainer::get().getResMgr( aPrefix, aLocale, true ); + m_pResImpl.reset(ResMgrContainer::get().getResMgr( aPrefix, aLocale, true )); DBG_ASSERT( m_pResImpl, "SimpleResMgr::SimpleResMgr : have no impl class !" ); } SimpleResMgr::~SimpleResMgr() { - delete m_pResImpl; } SimpleResMgr* SimpleResMgr::Create(const sal_Char* pPrefixName, const LanguageTag& rLocale) @@ -1451,7 +1450,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId ) return sReturn; void* pResHandle = nullptr; - InternalResMgr* pFallback = m_pResImpl; + InternalResMgr* pFallback = m_pResImpl.get(); RSHEADER_TYPE* pResHeader = static_cast<RSHEADER_TYPE*>(m_pResImpl->LoadGlobalRes( RSC_STRING, nId, &pResHandle )); if ( !pResHeader ) { @@ -1462,7 +1461,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId ) { InternalResMgr* pOldFallback = pFallback; pFallback = ResMgrContainer::get().getNextFallback( pFallback ); - if( pOldFallback != m_pResImpl ) + if( pOldFallback != m_pResImpl.get() ) ResMgrContainer::get().freeResMgr( pOldFallback ); if( pFallback ) { @@ -1489,7 +1488,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId ) // not necessary with the current implementation which holds the string table permanently, but to be sure .... // note: pFallback cannot be NULL here and is either the fallback or m_pResImpl InternalResMgr::FreeGlobalRes( pResHeader, pResHandle ); - if( m_pResImpl != pFallback ) + if( m_pResImpl.get() != pFallback ) { osl::Guard<osl::Mutex> aGuard2( getResMgrMutex() ); |