summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-26 09:48:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-13 11:56:05 +0200
commit51a50cc95a8cb461b7026c1eb8908e17f4055076 (patch)
tree01d3062cc93857684ec40a5b162b62178f89558b /sc
parent7274490e8af1de05ab84b5e08017a3378502ea96 (diff)
improve useuniqueptr loplugin to find arrays
Change-Id: I81e9d0cd4f430b11d20037054055683240792240 Reviewed-on: https://gerrit.libreoffice.org/39825 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/tokstack.cxx38
-rw-r--r--sc/source/filter/inc/tokstack.hxx11
2 files changed, 19 insertions, 30 deletions
diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx
index cb5a42805b88..daf638e41fa8 100644
--- a/sc/source/filter/excel/tokstack.cxx
+++ b/sc/source/filter/excel/tokstack.cxx
@@ -48,18 +48,18 @@ TokenPool::TokenPool( svl::SharedStringPool& rSPool ) :
{
// pool for Id-sequences
nP_Id = 256;
- pP_Id = new sal_uInt16[ nP_Id ];
+ pP_Id.reset( new sal_uInt16[ nP_Id ] );
// pool for Ids
nElement = 32;
- pElement = new sal_uInt16[ nElement ];
- pType = new E_TYPE[ nElement ];
- pSize = new sal_uInt16[ nElement ];
+ pElement.reset( new sal_uInt16[ nElement ] );
+ pType.reset( new E_TYPE[ nElement ] );
+ pSize.reset( new sal_uInt16[ nElement ] );
nP_IdLast = 0;
nP_Matrix = 16;
- ppP_Matrix = new ScMatrix*[ nP_Matrix ];
- memset( ppP_Matrix, 0, sizeof( ScMatrix* ) * nP_Matrix );
+ ppP_Matrix.reset( new ScMatrix*[ nP_Matrix ] );
+ memset( ppP_Matrix.get(), 0, sizeof( ScMatrix* ) * nP_Matrix );
pScToken = new ScTokenArray;
@@ -68,13 +68,7 @@ TokenPool::TokenPool( svl::SharedStringPool& rSPool ) :
TokenPool::~TokenPool()
{
- delete[] pP_Id;
- delete[] pElement;
- delete[] pType;
- delete[] pSize;
-
ClearMatrix();
- delete[] ppP_Matrix;
delete pScToken;
}
@@ -110,8 +104,7 @@ bool TokenPool::GrowId()
nP_Id = nP_IdNew;
- delete[] pP_Id;
- pP_Id = pP_IdNew;
+ pP_Id.reset( pP_IdNew );
return true;
}
@@ -141,12 +134,9 @@ bool TokenPool::GrowElement()
nElement = nElementNew;
- delete[] pElement;
- delete[] pType;
- delete[] pSize;
- pElement = pElementNew;
- pType = pTypeNew;
- pSize = pSizeNew;
+ pElement.reset( pElementNew );
+ pType.reset( pTypeNew );
+ pSize.reset( pSizeNew );
return true;
}
@@ -161,10 +151,10 @@ bool TokenPool::GrowMatrix()
return false;
memset( ppNew, 0, sizeof( ScMatrix* ) * nNewSize );
- memcpy( ppNew, ppP_Matrix, sizeof( ScMatrix* ) * nP_Matrix );
+ for( sal_uInt16 nL = 0 ; nL < nP_Matrix ; nL++ )
+ ppNew[ nL ] = ppP_Matrix[ nL ];
- delete[] ppP_Matrix;
- ppP_Matrix = ppNew;
+ ppP_Matrix.reset( ppNew );
nP_Matrix = nNewSize;
return true;
}
@@ -202,6 +192,7 @@ bool TokenPool::GetElement( const sal_uInt16 nId )
}
break;
case T_Err:
+ break;
/* TODO: in case we had FormulaTokenArray::AddError() */
#if 0
{
@@ -212,7 +203,6 @@ bool TokenPool::GetElement( const sal_uInt16 nId )
bRet = false;
}
#endif
- break;
case T_RefC:
{
sal_uInt16 n = pElement[ nId ];
diff --git a/sc/source/filter/inc/tokstack.hxx b/sc/source/filter/inc/tokstack.hxx
index eca4d346e723..39c6561980e4 100644
--- a/sc/source/filter/inc/tokstack.hxx
+++ b/sc/source/filter/inc/tokstack.hxx
@@ -145,8 +145,7 @@ private:
TokenPoolPool<std::unique_ptr<ScSingleRefData>, 32>
ppP_RefTr; // Pool for References
-
- sal_uInt16* pP_Id; // Pool for Id-sets
+ std::unique_ptr<sal_uInt16[]> pP_Id; // Pool for Id-sets
sal_uInt16 nP_Id;
sal_uInt16 nP_IdAkt;
sal_uInt16 nP_IdLast; // last set-start
@@ -164,7 +163,7 @@ private:
TokenPoolPool<std::unique_ptr<ScSingleRefData>, 16>
ppP_Nlf;
- ScMatrix** ppP_Matrix; // Pool for Matrices
+ std::unique_ptr<ScMatrix*[]> ppP_Matrix; // Pool for Matrices
sal_uInt16 nP_Matrix;
sal_uInt16 nP_MatrixAkt;
@@ -202,9 +201,9 @@ private:
};
::std::vector<ExtAreaRef> maExtAreaRefs;
- sal_uInt16* pElement; // Array with Indices for elements
- E_TYPE* pType; // ...with Type-Info
- sal_uInt16* pSize; // ...with size (Anz. sal_uInt16)
+ std::unique_ptr<sal_uInt16[]> pElement; // Array with Indices for elements
+ std::unique_ptr<E_TYPE[]> pType; // ...with Type-Info
+ std::unique_ptr<sal_uInt16[]> pSize; // ...with size (Anz. sal_uInt16)
sal_uInt16 nElement;
sal_uInt16 nElementAkt;