summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-05 08:57:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-05 11:30:12 +0200
commitb0e05f9ade9e93c569c6a62c59ac1819e615f27b (patch)
tree61cbf40294b73e5dbc92213c23f1d89dd8998092
parent1a637473b5aa6a43acb4d1f820044fba962cc6a4 (diff)
loplugin:useuniqueptr in basic..cppcanvas
Change-Id: Ib40241eb794607154ae52f8aa68fbf5ea5e944af Reviewed-on: https://gerrit.libreoffice.org/39551 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/inc/runtime.hxx19
-rw-r--r--basic/source/runtime/runtime.cxx11
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.cxx9
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.hxx11
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx4
-rw-r--r--chart2/source/view/main/ChartItemPool.hxx3
-rw-r--r--connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx4
-rw-r--r--connectivity/source/drivers/odbc/OResultSet.cxx14
-rw-r--r--connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx3
-rw-r--r--connectivity/source/inc/odbc/OResultSet.hxx7
-rw-r--r--cppcanvas/source/mtfrenderer/emfppath.cxx8
-rw-r--r--cppcanvas/source/mtfrenderer/emfppath.hxx6
-rwxr-xr-xcppcanvas/source/mtfrenderer/emfppen.cxx21
-rwxr-xr-xcppcanvas/source/mtfrenderer/emfppen.hxx7
14 files changed, 52 insertions, 75 deletions
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 4c7dfa965c9d..6b390ff2f078 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -65,26 +65,19 @@ struct SbiForStack { // for/next stack:
// For each support
ForType eForType;
sal_Int32 nCurCollectionIndex;
- sal_Int32* pArrayCurIndices;
- sal_Int32* pArrayLowerBounds;
- sal_Int32* pArrayUpperBounds;
+ std::unique_ptr<sal_Int32[]>
+ pArrayCurIndices;
+ std::unique_ptr<sal_Int32[]>
+ pArrayLowerBounds;
+ std::unique_ptr<sal_Int32[]>
+ pArrayUpperBounds;
css::uno::Reference< css::container::XEnumeration > xEnumeration;
SbiForStack()
: pNext(nullptr)
, eForType(ForType::To)
, nCurCollectionIndex(0)
- , pArrayCurIndices(nullptr)
- , pArrayLowerBounds(nullptr)
- , pArrayUpperBounds(nullptr)
{}
-
- ~SbiForStack()
- {
- delete[] pArrayCurIndices;
- delete[] pArrayLowerBounds;
- delete[] pArrayUpperBounds;
- }
};
#define MAXRECURSION 500
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 41e3e8afd7e6..6038dadd736e 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1122,9 +1122,9 @@ void SbiRuntime::PushForEach()
p->refEnd = reinterpret_cast<SbxVariable*>(pArray);
short nDims = pArray->GetDims();
- p->pArrayLowerBounds = new sal_Int32[nDims];
- p->pArrayUpperBounds = new sal_Int32[nDims];
- p->pArrayCurIndices = new sal_Int32[nDims];
+ p->pArrayLowerBounds.reset( new sal_Int32[nDims] );
+ p->pArrayUpperBounds.reset( new sal_Int32[nDims] );
+ p->pArrayCurIndices.reset( new sal_Int32[nDims] );
sal_Int32 lBound, uBound;
for( short i = 0 ; i < nDims ; i++ )
{
@@ -2985,7 +2985,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
bEndLoop = true;
break;
}
- SbxVariable* pVal = pArray->Get32( p->pArrayCurIndices );
+ SbxVariable* pVal = pArray->Get32( p->pArrayCurIndices.get() );
*(p->refVar) = *pVal;
bool bFoundNext = false;
@@ -3002,8 +3002,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
}
if( !bFoundNext )
{
- delete[] p->pArrayCurIndices;
- p->pArrayCurIndices = nullptr;
+ p->pArrayCurIndices.reset();
}
}
break;
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
index ebbeb4cb304b..df37b2ef07fd 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
@@ -450,10 +450,10 @@ void EquidistantTickIter::initIter( sal_Int32 nMaxDepth )
if(!m_nTickCount)
return;
- m_pnPositions = new sal_Int32[m_nMaxDepth+1];
+ m_pnPositions.reset( new sal_Int32[m_nMaxDepth+1] );
- m_pnPreParentCount = new sal_Int32[m_nMaxDepth+1];
- m_pbIntervalFinished = new bool[m_nMaxDepth+1];
+ m_pnPreParentCount.reset( new sal_Int32[m_nMaxDepth+1] );
+ m_pbIntervalFinished.reset( new bool[m_nMaxDepth+1] );
m_pnPreParentCount[0] = 0;
m_pbIntervalFinished[0] = false;
double fParentValue = getTickValue(0,0);
@@ -482,9 +482,6 @@ void EquidistantTickIter::initIter( sal_Int32 nMaxDepth )
EquidistantTickIter::~EquidistantTickIter()
{
- delete[] m_pnPositions;
- delete[] m_pnPreParentCount;
- delete[] m_pbIntervalFinished;
}
sal_Int32 EquidistantTickIter::getStartDepth() const
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.hxx b/chart2/source/view/axes/Tickmarks_Equidistant.hxx
index 2f60c694622c..72897c048311 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.hxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.hxx
@@ -19,8 +19,8 @@
#ifndef INCLUDED_CHART2_SOURCE_VIEW_AXES_TICKMARKS_EQUIDISTANT_HXX
#define INCLUDED_CHART2_SOURCE_VIEW_AXES_TICKMARKS_EQUIDISTANT_HXX
-#include <memory>
#include "Tickmarks.hxx"
+#include <memory>
namespace chart
{
@@ -80,10 +80,13 @@ private: //member
const ExplicitIncrementData& m_rIncrement;
sal_Int32 m_nMaxDepth;
sal_Int32 m_nTickCount;
- sal_Int32* m_pnPositions; //current positions in the different sequences
- sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always,
+ std::unique_ptr<sal_Int32[]>
+ m_pnPositions; //current positions in the different sequences
+ std::unique_ptr<sal_Int32[]>
+ m_pnPreParentCount; //the tickmarks do not start with a major tick always,
//the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark
- bool* m_pbIntervalFinished;
+ std::unique_ptr<bool[]>
+ m_pbIntervalFinished;
sal_Int32 m_nCurrentDepth;
sal_Int32 m_nCurrentPos;
double m_fCurrentValue;
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index 22a99d8b8f87..1743ae0741fd 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -177,7 +177,7 @@ ChartItemPool::ChartItemPool():
pItemInfos[SCHATTR_SYMBOL_SIZE - SCHATTR_START]._nSID = SID_ATTR_SYMBOLSIZE;
SetDefaults(ppPoolDefaults);
- SetItemInfos(pItemInfos);
+ SetItemInfos(pItemInfos.get());
}
ChartItemPool::ChartItemPool(const ChartItemPool& rPool):
@@ -190,8 +190,6 @@ ChartItemPool::~ChartItemPool()
Delete();
// release and delete static pool default items
ReleaseDefaults(true);
-
- delete[] pItemInfos;
}
SfxItemPool* ChartItemPool::Clone() const
diff --git a/chart2/source/view/main/ChartItemPool.hxx b/chart2/source/view/main/ChartItemPool.hxx
index ad183e87aa41..82ebb0cc73e6 100644
--- a/chart2/source/view/main/ChartItemPool.hxx
+++ b/chart2/source/view/main/ChartItemPool.hxx
@@ -21,13 +21,14 @@
#include <svl/poolitem.hxx>
#include <svl/itempool.hxx>
+#include <memory>
namespace chart
{
class ChartItemPool : public SfxItemPool
{
private:
- SfxItemInfo* pItemInfos;
+ std::unique_ptr<SfxItemInfo[]> pItemInfos;
public:
ChartItemPool();
diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
index 44da0bb72aac..796f34a786c2 100644
--- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx
@@ -68,9 +68,8 @@ ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection
throw RuntimeException();
osl_atomic_increment( &m_refCount );
- m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
+ m_pRowStatusArray.reset( new SQLUSMALLINT[1] ); // the default value
osl_atomic_decrement( &m_refCount );
- // allocBuffer();
}
@@ -82,7 +81,6 @@ ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
osl_atomic_increment( &m_refCount );
dispose();
}
- delete [] m_pRowStatusArray;
}
void ODatabaseMetaDataResultSet::disposing()
diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx
index 475d2fe286b4..203402eb5b35 100644
--- a/connectivity/source/drivers/odbc/OResultSet.cxx
+++ b/connectivity/source/drivers/odbc/OResultSet.cxx
@@ -104,8 +104,8 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
osl_atomic_increment( &m_refCount );
try
{
- m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
- setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray);
+ m_pRowStatusArray.reset( new SQLUSMALLINT[1] ); // the default value
+ setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray.get());
}
catch(const Exception&)
{ // we don't want our result destroy here
@@ -117,7 +117,7 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,false);
if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
(nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)
- m_pSkipDeletedSet = new OSkipDeletedSet(this);
+ m_pSkipDeletedSet.reset( new OSkipDeletedSet(this) );
}
catch(const Exception&)
{ // we don't want our result destroy here
@@ -164,8 +164,6 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
OResultSet::~OResultSet()
{
- delete [] m_pRowStatusArray;
- delete m_pSkipDeletedSet;
}
void OResultSet::construct()
@@ -1389,10 +1387,8 @@ void OResultSet::setFetchSize(sal_Int32 _par0)
if ( _par0 > 0 )
{
setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE, _par0);
- delete [] m_pRowStatusArray;
-
- m_pRowStatusArray = new SQLUSMALLINT[_par0];
- setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray);
+ m_pRowStatusArray.reset( new SQLUSMALLINT[_par0] );
+ setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray.get());
}
}
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
index 56e3b5062bbf..c242c2eee85c 100644
--- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -39,6 +39,7 @@
#include "odbc/ODatabaseMetaData.hxx"
#include "odbc/odbcbasedllapi.hxx"
#include <connectivity/StdTypeDefs.hxx>
+#include <memory>
namespace connectivity
{
@@ -72,7 +73,7 @@ namespace connectivity
css::uno::WeakReferenceHelper m_aStatement;
css::uno::Reference< css::sdbc::XResultSetMetaData>
m_xMetaData;
- SQLUSMALLINT* m_pRowStatusArray;
+ std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray;
rtl::Reference<OConnection> m_pConnection;
rtl_TextEncoding m_nTextEncoding;
sal_Int32 m_nRowPos;
diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx
index b09310519698..d1f75371cfe0 100644
--- a/connectivity/source/inc/odbc/OResultSet.hxx
+++ b/connectivity/source/inc/odbc/OResultSet.hxx
@@ -40,6 +40,7 @@
#include <connectivity/CommonTools.hxx>
#include <connectivity/FValue.hxx>
#include "TSkipDeletedSet.hxx"
+#include <memory>
namespace connectivity
{
@@ -130,14 +131,14 @@ namespace connectivity
// Else, we read and cache all columns whose number is <= a requested column.
// m_aRow[colNumber].getBound() says if it contains an up-to-date value or not.
TDataRow m_aRow;
- bool m_bFetchDataInOrder;
+ bool m_bFetchDataInOrder;
SQLHANDLE m_aStatementHandle;
SQLHANDLE m_aConnectionHandle;
OStatement_Base* m_pStatement;
- OSkipDeletedSet* m_pSkipDeletedSet;
+ std::unique_ptr<OSkipDeletedSet> m_pSkipDeletedSet;
css::uno::Reference< css::uno::XInterface> m_xStatement;
css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData;
- SQLUSMALLINT* m_pRowStatusArray;
+ std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray;
rtl_TextEncoding m_nTextEncoding;
sal_Int32 m_nRowPos;
mutable sal_uInt32 m_nUseBookmarks;
diff --git a/cppcanvas/source/mtfrenderer/emfppath.cxx b/cppcanvas/source/mtfrenderer/emfppath.cxx
index d924ce61d816..749bc900cc62 100644
--- a/cppcanvas/source/mtfrenderer/emfppath.cxx
+++ b/cppcanvas/source/mtfrenderer/emfppath.cxx
@@ -50,17 +50,13 @@ namespace cppcanvas
if( _nPoints<0 || sal_uInt32(_nPoints)>SAL_MAX_INT32/(2*sizeof(float)) )
_nPoints = SAL_MAX_INT32/(2*sizeof(float));
nPoints = _nPoints;
- pPoints = new float [nPoints*2];
+ pPoints.reset( new float [nPoints*2] );
if (!bLines)
- pPointTypes = new sal_uInt8 [_nPoints];
- else
- pPointTypes = nullptr;
+ pPointTypes.reset( new sal_uInt8 [_nPoints] );
}
EMFPPath::~EMFPPath ()
{
- delete [] pPoints;
- delete [] pPointTypes;
}
// TODO: remove rR argument when debug code is no longer needed
diff --git a/cppcanvas/source/mtfrenderer/emfppath.hxx b/cppcanvas/source/mtfrenderer/emfppath.hxx
index 7ced476358e9..f4e92937e432 100644
--- a/cppcanvas/source/mtfrenderer/emfppath.hxx
+++ b/cppcanvas/source/mtfrenderer/emfppath.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPATH_HXX
#define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPATH_HXX
+#include <memory>
+
namespace cppcanvas
{
namespace internal
@@ -28,8 +30,8 @@ namespace cppcanvas
{
::basegfx::B2DPolyPolygon aPolygon;
sal_Int32 nPoints;
- float* pPoints;
- sal_uInt8* pPointTypes;
+ std::unique_ptr<float[]> pPoints;
+ std::unique_ptr<sal_uInt8[]> pPointTypes;
EMFPPath(sal_Int32 _nPoints, bool bLines = false);
diff --git a/cppcanvas/source/mtfrenderer/emfppen.cxx b/cppcanvas/source/mtfrenderer/emfppen.cxx
index b3b0c97dcb8a..36cf63acdf72 100755
--- a/cppcanvas/source/mtfrenderer/emfppen.cxx
+++ b/cppcanvas/source/mtfrenderer/emfppen.cxx
@@ -81,11 +81,7 @@ namespace cppcanvas
, dashStyle(0)
, dashCap(0)
, dashOffset(0.0)
- , dashPatternLen(0)
- , dashPattern(nullptr)
, alignment(0)
- , compoundArrayLen(0)
- , compoundArray(nullptr)
, customStartCapLen(0)
, customStartCap(nullptr)
, customEndCapLen(0)
@@ -95,8 +91,6 @@ namespace cppcanvas
EMFPPen::~EMFPPen()
{
- delete[] dashPattern;
- delete[] compoundArray;
delete customStartCap;
delete customEndCap;
}
@@ -162,7 +156,7 @@ namespace cppcanvas
case EmfPlusLineStyleDot: nLen = SAL_N_ELEMENTS(dot); pPattern = dot; break;
case EmfPlusLineStyleDashDot: nLen = SAL_N_ELEMENTS(dashdot); pPattern = dashdot; break;
case EmfPlusLineStyleDashDotDot: nLen = SAL_N_ELEMENTS(dashdotdot); pPattern = dashdotdot; break;
- case EmfPlusLineStyleCustom: nLen = dashPatternLen; pPattern = dashPattern; break;
+ case EmfPlusLineStyleCustom: nLen = dashPattern.size(); pPattern = dashPattern.data(); break;
}
if (nLen > 0)
{
@@ -236,37 +230,36 @@ namespace cppcanvas
if (penDataFlags & PenDataDashedLine)
{
dashStyle = EmfPlusLineStyleCustom;
+ sal_Int32 dashPatternLen;
s.ReadInt32(dashPatternLen);
SAL_INFO("cppcanvas.emf", "EMF+\t\tdashPatternLen: " << dashPatternLen);
if (dashPatternLen<0 || sal_uInt32(dashPatternLen)>SAL_MAX_INT32 / sizeof(float))
dashPatternLen = SAL_MAX_INT32 / sizeof(float);
- dashPattern = new float[dashPatternLen];
+ dashPattern.resize( dashPatternLen );
for (i = 0; i < dashPatternLen; i++)
{
s.ReadFloat(dashPattern[i]);
SAL_INFO("cppcanvas.emf", "EMF+\t\t\tdashPattern[" << i << "]: " << dashPattern[i]);
}
}
- else
- dashPatternLen = 0;
if (penDataFlags & PenDataNonCenter)
s.ReadInt32(alignment);
else
alignment = 0;
- if (penDataFlags & PenDataCompoundLine) {
+ if (penDataFlags & PenDataCompoundLine)
+ {
+ sal_Int32 compoundArrayLen;
s.ReadInt32(compoundArrayLen);
if (compoundArrayLen<0 || sal_uInt32(compoundArrayLen)>SAL_MAX_INT32 / sizeof(float))
compoundArrayLen = SAL_MAX_INT32 / sizeof(float);
- compoundArray = new float[compoundArrayLen];
+ compoundArray.resize(compoundArrayLen);
for (i = 0; i < compoundArrayLen; i++)
s.ReadFloat(compoundArray[i]);
}
- else
- compoundArrayLen = 0;
if (penDataFlags & PenDataCustomStartCap)
{
diff --git a/cppcanvas/source/mtfrenderer/emfppen.hxx b/cppcanvas/source/mtfrenderer/emfppen.hxx
index f4b1650b0bf1..7e2bd9e8e7db 100755
--- a/cppcanvas/source/mtfrenderer/emfppen.hxx
+++ b/cppcanvas/source/mtfrenderer/emfppen.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPEN_HXX
#include <emfpbrush.hxx>
+#include <vector>
namespace cppcanvas
{
@@ -47,11 +48,9 @@ namespace cppcanvas
sal_Int32 dashStyle;
sal_Int32 dashCap;
float dashOffset;
- sal_Int32 dashPatternLen;
- float *dashPattern;
+ std::vector<float> dashPattern;
sal_Int32 alignment;
- sal_Int32 compoundArrayLen;
- float *compoundArray;
+ std::vector<float> compoundArray;
sal_Int32 customStartCapLen;
EMFPCustomLineCap *customStartCap;
sal_Int32 customEndCapLen;