summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-08 10:33:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-14 17:12:51 +0200
commit7ebb57228f27a95eb1648500b5becb3febb9d316 (patch)
tree67325c19fc6ce0de57f279588feea3e758f86043 /formula
parent38fa68b90ae50d9bf25cf22fef36e030282b44a3 (diff)
loplugin:useuniqueptr in FormulaTokenArray
Change-Id: I5716295d2f0c88c6daf0570941d5dd4c5ff03a33 Reviewed-on: https://gerrit.libreoffice.org/54168 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/token.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 1d33b4d93571..649a8d36c443 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -605,8 +605,9 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r )
FormulaToken** pp;
if( nLen )
{
- pp = pCode = new FormulaToken*[ nLen ];
- memcpy( pp, r.pCode, nLen * sizeof( FormulaToken* ) );
+ pCode.reset(new FormulaToken*[ nLen ]);
+ pp = pCode.get();
+ memcpy( pp, r.pCode.get(), nLen * sizeof( FormulaToken* ) );
for( sal_uInt16 i = 0; i < nLen; i++ )
(*pp++)->IncRef();
mbFinalized = true;
@@ -627,7 +628,7 @@ void FormulaTokenArray::Assign( sal_uInt16 nCode, FormulaToken **pTokens )
assert( pCode == nullptr );
nLen = nCode;
- pCode = new FormulaToken*[ nLen ];
+ pCode.reset(new FormulaToken*[ nLen ]);
mbFinalized = true;
for( sal_uInt16 i = 0; i < nLen; i++ )
@@ -651,14 +652,14 @@ void FormulaTokenArray::Clear()
if( nRPN ) DelRPN();
if( pCode )
{
- FormulaToken** p = pCode;
+ FormulaToken** p = pCode.get();
for( sal_uInt16 i = 0; i < nLen; i++ )
{
(*p++)->DecRef();
}
- delete [] pCode;
+ pCode.reset();
}
- pCode = nullptr; pRPN = nullptr;
+ pRPN = nullptr;
nError = FormulaError::NONE;
nLen = nRPN = 0;
bHyperLink = false;
@@ -775,7 +776,7 @@ FormulaToken* FormulaTokenArray::Add( FormulaToken* t )
}
if( !pCode )
- pCode = new FormulaToken*[ FORMULA_MAXTOKENS ];
+ pCode.reset(new FormulaToken*[ FORMULA_MAXTOKENS ]);
if( nLen < FORMULA_MAXTOKENS - 1 )
{
CheckToken(*t);