summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/misc/instancelocker.cxx8
-rw-r--r--comphelper/source/misc/instancelocker.hxx3
-rw-r--r--cppu/source/typelib/typelib.cxx18
-rw-r--r--registry/source/reflread.cxx35
4 files changed, 17 insertions, 47 deletions
diff --git a/comphelper/source/misc/instancelocker.cxx b/comphelper/source/misc/instancelocker.cxx
index 76d2cd1a761a..ec0b27f4180b 100644
--- a/comphelper/source/misc/instancelocker.cxx
+++ b/comphelper/source/misc/instancelocker.cxx
@@ -58,12 +58,6 @@ OInstanceLocker::~OInstanceLocker()
catch ( uno::RuntimeException& )
{}
}
-
- if ( m_pListenersContainer )
- {
- delete m_pListenersContainer;
- m_pListenersContainer = nullptr;
- }
}
// XComponent
@@ -96,7 +90,7 @@ void SAL_CALL OInstanceLocker::addEventListener( const uno::Reference< lang::XEv
throw lang::DisposedException(); // TODO
if ( !m_pListenersContainer )
- m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex );
+ m_pListenersContainer.reset( new ::comphelper::OInterfaceContainerHelper2( m_aMutex ) );
m_pListenersContainer->addInterface( xListener );
}
diff --git a/comphelper/source/misc/instancelocker.hxx b/comphelper/source/misc/instancelocker.hxx
index cb6d229fc2dd..fb6581317006 100644
--- a/comphelper/source/misc/instancelocker.hxx
+++ b/comphelper/source/misc/instancelocker.hxx
@@ -33,6 +33,7 @@
#include <cppuhelper/implbase.hxx>
#include <comphelper/interfacecontainer2.hxx>
#include <rtl/ref.hxx>
+#include <memory>
class OLockListener;
@@ -47,7 +48,7 @@ class OInstanceLocker : public ::cppu::WeakImplHelper< css::lang::XComponent,
rtl::Reference< OLockListener > m_xLockListener;
- ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners
+ std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
bool m_bDisposed;
bool m_bInitialized;
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 9bdd27c257ec..bf44d6a850dc 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -173,11 +173,11 @@ struct TypeDescriptor_Init_Impl
{
//sal_Bool bDesctructorCalled;
// all type description references
- WeakMap_Impl * pWeakMap;
+ std::unique_ptr<WeakMap_Impl> pWeakMap;
// all type description callbacks
std::unique_ptr<CallbackSet_Impl> pCallbacks;
// A cache to hold descriptions
- TypeDescriptionList_Impl * pCache;
+ std::unique_ptr<TypeDescriptionList_Impl> pCache;
// The mutex to guard all type library accesses
std::unique_ptr<Mutex> pMutex;
@@ -253,8 +253,6 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
typelib_typedescription_release( *aIt );
++aIt;
}
- delete pCache;
- pCache = nullptr;
}
if( pWeakMap )
@@ -304,8 +302,6 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl()
++aIt;
}
#endif
- delete pWeakMap;
- pWeakMap = nullptr;
}
#if OSL_DEBUG_LEVEL > 0
SAL_INFO_IF( nTypeDescriptionCount, "cppu.typelib", "nTypeDescriptionCount is not zero" );
@@ -504,7 +500,7 @@ bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
// insert into the chache
MutexGuard aGuard( rInit.getMutex() );
if( !rInit.pCache )
- rInit.pCache = new TypeDescriptionList_Impl;
+ rInit.pCache.reset( new TypeDescriptionList_Impl );
if( static_cast<sal_Int32>(rInit.pCache->size()) >= nCacheSize )
{
typelib_typedescription_release( rInit.pCache->front() );
@@ -1560,7 +1556,7 @@ extern "C" void SAL_CALL typelib_typedescription_register(
{
pTDR = reinterpret_cast<typelib_TypeDescriptionReference *>(*ppNewDescription);
if( !rInit.pWeakMap )
- rInit.pWeakMap = new WeakMap_Impl;
+ rInit.pWeakMap.reset( new WeakMap_Impl );
// description is the weak itself, so register it
(*rInit.pWeakMap)[pTDR->pTypeName->buffer] = pTDR;
@@ -2001,7 +1997,7 @@ extern "C" void SAL_CALL typelib_typedescription_getByName(
// insert into the chache
MutexGuard aGuard( rInit.getMutex() );
if( !rInit.pCache )
- rInit.pCache = new TypeDescriptionList_Impl;
+ rInit.pCache.reset( new TypeDescriptionList_Impl );
if( static_cast<sal_Int32>(rInit.pCache->size()) >= nCacheSize )
{
typelib_typedescription_release( rInit.pCache->front() );
@@ -2059,7 +2055,7 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_new(
// insert into the chache
MutexGuard aGuard( rInit.getMutex() );
if( !rInit.pCache )
- rInit.pCache = new TypeDescriptionList_Impl;
+ rInit.pCache.reset( new TypeDescriptionList_Impl );
if( static_cast<sal_Int32>(rInit.pCache->size()) >= nCacheSize )
{
typelib_typedescription_release( rInit.pCache->front() );
@@ -2112,7 +2108,7 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_new(
}
if( !rInit.pWeakMap )
- rInit.pWeakMap = new WeakMap_Impl;
+ rInit.pWeakMap.reset( new WeakMap_Impl );
// Heavy hack, the const sal_Unicode * is hold by the typedescription reference
// not registered
rInit.pWeakMap->operator[]( (*ppTDR)->pTypeName->buffer ) = *ppTDR;
diff --git a/registry/source/reflread.cxx b/registry/source/reflread.cxx
index 57ce8b9e3172..8ee681537307 100644
--- a/registry/source/reflread.cxx
+++ b/registry/source/reflread.cxx
@@ -22,6 +22,7 @@
#include <cstring>
#include <memory>
#include <new>
+#include <vector>
#include <string.h>
#include <sal/types.h>
@@ -185,60 +186,38 @@ BlopObject::~BlopObject()
class StringCache
{
public:
- sal_Unicode** m_stringTable;
- sal_uInt16 m_numOfStrings;
+ std::vector<std::unique_ptr<sal_Unicode[]>> m_stringTable;
sal_uInt16 m_stringsCopied;
explicit StringCache(sal_uInt16 size); // throws std::bad_alloc
- ~StringCache();
const sal_Unicode* getString(sal_uInt16 index) const;
sal_uInt16 createString(const sal_uInt8* buffer); // throws std::bad_alloc
};
StringCache::StringCache(sal_uInt16 size)
- : m_stringTable(nullptr)
- , m_numOfStrings(size)
+ : m_stringTable(size)
, m_stringsCopied(0)
{
- m_stringTable = new sal_Unicode*[m_numOfStrings];
-
- for (sal_uInt16 i = 0; i < m_numOfStrings; i++)
- {
- m_stringTable[i] = nullptr;
- }
-}
-
-StringCache::~StringCache()
-{
- if (m_stringTable)
- {
- for (sal_uInt16 i = 0; i < m_stringsCopied; i++)
- {
- delete[] m_stringTable[i];
- }
-
- delete[] m_stringTable;
- }
}
const sal_Unicode* StringCache::getString(sal_uInt16 index) const
{
if ((index > 0) && (index <= m_stringsCopied))
- return m_stringTable[index - 1];
+ return m_stringTable[index - 1].get();
else
return nullptr;
}
sal_uInt16 StringCache::createString(const sal_uInt8* buffer)
{
- if (m_stringsCopied < m_numOfStrings)
+ if (m_stringsCopied < m_stringTable.size())
{
sal_uInt32 len = UINT16StringLen(buffer);
- m_stringTable[m_stringsCopied] = new sal_Unicode[len + 1];
+ m_stringTable[m_stringsCopied].reset( new sal_Unicode[len + 1] );
- readString(buffer, m_stringTable[m_stringsCopied], (len + 1) * sizeof(sal_Unicode));
+ readString(buffer, m_stringTable[m_stringsCopied].get(), (len + 1) * sizeof(sal_Unicode));
return ++m_stringsCopied;
}