summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-10 12:30:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-11 12:47:37 +0100
commite57a036939e27ecd173ace691689e26a6a33df8e (patch)
treea36d589da272c4732cddb4ca0548cdb5dcb2b2bd /stoc
parentcb5d79b504aa8575ea15c777707c7465ea43cb07 (diff)
loplugin:useuniqueptr in tools,stoc,unotools
Change-Id: Ia72b65577143623cedc7a40bc34f7fb897add097 Reviewed-on: https://gerrit.libreoffice.org/47726 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/corereflection/base.hxx2
-rw-r--r--stoc/source/corereflection/criface.cxx45
2 files changed, 17 insertions, 30 deletions
diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx
index fe15a10a75ac..4c05b91078c9 100644
--- a/stoc/source/corereflection/base.hxx
+++ b/stoc/source/corereflection/base.hxx
@@ -197,7 +197,7 @@ class InterfaceIdlClassImpl
css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > _xSuperClasses;
- MemberInit * _pSortedMemberInit; // first methods, then attributes
+ std::unique_ptr<MemberInit[]> _pSortedMemberInit; // first methods, then attributes
OUString2Field _aName2Field;
OUString2Method _aName2Method;
sal_Int32 _nMethods;
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx
index 91177f626246..fddaff0b4b6a 100644
--- a/stoc/source/corereflection/criface.cxx
+++ b/stoc/source/corereflection/criface.cxx
@@ -327,9 +327,9 @@ class IdlInterfaceMethodImpl
: public IdlMemberImpl
, public XIdlMethod
{
- Sequence< Reference< XIdlClass > > * _pExceptionTypes;
- Sequence< Reference< XIdlClass > > * _pParamTypes;
- Sequence< ParamInfo > * _pParamInfos;
+ std::unique_ptr<Sequence< Reference< XIdlClass > >> _pExceptionTypes;
+ std::unique_ptr<Sequence< Reference< XIdlClass > >> _pParamTypes;
+ std::unique_ptr<Sequence< ParamInfo >> _pParamInfos;
public:
typelib_InterfaceMethodTypeDescription * getMethodTypeDescr() const
@@ -338,11 +338,7 @@ public:
IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
: IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
- , _pExceptionTypes( nullptr )
- , _pParamTypes( nullptr )
- , _pParamInfos( nullptr )
{}
- virtual ~IdlInterfaceMethodImpl() override;
// XInterface
virtual Any SAL_CALL queryInterface( const Type & rType ) override;
@@ -365,13 +361,6 @@ public:
virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) override;
};
-IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl()
-{
- delete _pParamInfos;
- delete _pParamTypes;
- delete _pExceptionTypes;
-}
-
// XInterface
Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
@@ -452,8 +441,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
if (! _pExceptionTypes)
{
sal_Int32 nExc = getMethodTypeDescr()->nExceptions;
- Sequence< Reference< XIdlClass > > * pTempExceptionTypes =
- new Sequence< Reference< XIdlClass > >( nExc );
+ std::unique_ptr<Sequence< Reference< XIdlClass > >> pTempExceptionTypes(
+ new Sequence< Reference< XIdlClass > >( nExc ));
Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
typelib_TypeDescriptionReference ** ppExc =
@@ -463,7 +452,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
while (nExc--)
pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
- _pExceptionTypes = pTempExceptionTypes;
+ _pExceptionTypes = std::move(pTempExceptionTypes);
}
}
return *_pExceptionTypes;
@@ -477,8 +466,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
if (! _pParamTypes)
{
sal_Int32 nParams = getMethodTypeDescr()->nParams;
- Sequence< Reference< XIdlClass > > * pTempParamTypes =
- new Sequence< Reference< XIdlClass > >( nParams );
+ std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
+ new Sequence< Reference< XIdlClass > >( nParams ));
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
typelib_MethodParameter * pTypelibParams =
@@ -488,7 +477,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
while (nParams--)
pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
- _pParamTypes = pTempParamTypes;
+ _pParamTypes = std::move(pTempParamTypes);
}
}
return *_pParamTypes;
@@ -502,7 +491,7 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
if (! _pParamInfos)
{
sal_Int32 nParams = getMethodTypeDescr()->nParams;
- Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams );
+ std::unique_ptr<Sequence< ParamInfo > > pTempParamInfos( new Sequence< ParamInfo >( nParams ) );
ParamInfo * pParamInfos = pTempParamInfos->getArray();
typelib_MethodParameter * pTypelibParams =
@@ -526,8 +515,8 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
}
else // make also param types sequence if not already initialized
{
- Sequence< Reference< XIdlClass > > * pTempParamTypes =
- new Sequence< Reference< XIdlClass > >( nParams );
+ std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
+ new Sequence< Reference< XIdlClass > >( nParams ));
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
IdlReflectionServiceImpl * pRefl = getReflection();
@@ -544,10 +533,10 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
}
- _pParamTypes = pTempParamTypes;
+ _pParamTypes = std::move(pTempParamTypes);
}
- _pParamInfos = pTempParamInfos;
+ _pParamInfos = std::move(pTempParamInfos);
}
}
return *_pParamInfos;
@@ -759,8 +748,6 @@ InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
{
for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
typelib_typedescription_release( _pSortedMemberInit[nPos].second );
-
- delete [] _pSortedMemberInit;
}
@@ -782,7 +769,7 @@ Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
void InterfaceIdlClassImpl::initMembers()
{
sal_Int32 nAll = getTypeDescr()->nAllMembers;
- MemberInit * pSortedMemberInit = new MemberInit[nAll];
+ std::unique_ptr<MemberInit[]> pSortedMemberInit(new MemberInit[nAll]);
typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
@@ -808,7 +795,7 @@ void InterfaceIdlClassImpl::initMembers()
pSortedMemberInit[nIndex].second = pTD;
}
- _pSortedMemberInit = pSortedMemberInit;
+ _pSortedMemberInit = std::move(pSortedMemberInit);
}
sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )