summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-05 08:17:11 -0500
commit9ca19666511b1d44ba554a70cbbc0c8e2db844c6 (patch)
tree39a0bd694d2f1cf5d5a67082b85717e5bb2cbef0 /lotuswordpro
parent6346e8c08e789e6aa4f2041fab97ba14419dedd4 (diff)
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated and deleted inside a single local block, and the delete happening at the end of the block Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0) Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 (cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e)
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.cxx5
-rw-r--r--lotuswordpro/source/filter/lwpidxmgr.cxx19
-rw-r--r--lotuswordpro/source/filter/lwppara.cxx4
-rw-r--r--lotuswordpro/source/filter/lwptablelayout.cxx5
4 files changed, 14 insertions, 19 deletions
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index c3dc6450f7b0..ad59b6fb2b3d 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -706,13 +706,12 @@ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont)
bOk &= nEnd >= nBegin;
if (bOk)
{
- sal_uInt8* pEquData = new sal_uInt8[nEnd - nBegin + 1];
+ std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
{
pEquData[nIndex] = pGrafData[nBegin + nIndex];
}
- pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
- delete [] pEquData;
+ pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
}
pXFNote->Add(pXFNotePara);
diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index 94cd789e8fd0..c38c1a16bacf 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -68,6 +68,7 @@
#include "lwpidxmgr.hxx"
#include "lwptools.hxx"
+#include <memory>
const sal_uInt8 LwpIndexManager::MAXOBJECTIDS = 255;
@@ -246,19 +247,17 @@ void LwpIndexManager::ReadObjIndex( LwpSvStream *pStrm )
LwpObjectHeader ObjHdr;
ObjHdr.Read(*pStrm);
- LwpObjectStream* pObjStrm = new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
- static_cast<sal_uInt16>(ObjHdr.GetSize()) );
+ std::unique_ptr<LwpObjectStream> pObjStrm( new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(ObjHdr.GetSize()) ) );
if( (sal_uInt32)VO_OBJINDEX == ObjHdr.GetTag() )
{
- ReadObjIndexData( pObjStrm );
+ ReadObjIndexData( pObjStrm.get() );
}
else if( (sal_uInt32)VO_LEAFOBJINDEX == ObjHdr.GetTag() )
{
- ReadLeafData(pObjStrm);
+ ReadLeafData( pObjStrm.get() );
}
-
- delete pObjStrm;
}
/**
@@ -268,12 +267,10 @@ void LwpIndexManager::ReadLeafIndex( LwpSvStream *pStrm )
{
LwpObjectHeader ObjHdr;
ObjHdr.Read(*pStrm);
- LwpObjectStream* pObjStrm = new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
- static_cast<sal_uInt16>(ObjHdr.GetSize()) );
-
- ReadLeafData(pObjStrm);
+ std::unique_ptr<LwpObjectStream> pObjStrm( new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(ObjHdr.GetSize()) ) );
- delete pObjStrm;
+ ReadLeafData(pObjStrm.get());
}
/**
* @descr Read data in VO_LEAFOBJINDEX
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index d5ad1969df37..82192ec7073e 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -95,6 +95,7 @@
#include "lwpdropcapmgr.hxx"
#include "lwptable.hxx"
+#include <memory>
LwpPara::LwpPara(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
: LwpDLVList(objHdr, pStrm)
@@ -194,10 +195,9 @@ void LwpPara::Read()
{
if (Notify)
{
- LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
+ std::unique_ptr<LwpForked3NotifyList> pNotifyList( new LwpForked3NotifyList );
pNotifyList->GetExtraList().Read(m_pObjStrm.get());
pNotifyList->Read(m_pObjStrm.get());
- delete pNotifyList;
}
}
}
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 76f681a7a88b..c9acba7407e3 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -82,6 +82,7 @@
#include "xfilter/xffloatframe.hxx"
#include "lwpframelayout.hxx"
#include "xfilter/xfparastyle.hxx"
+#include <memory>
LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
: LwpPlacableLayout(objHdr, pStrm)
@@ -560,7 +561,7 @@ void LwpTableLayout::RegisterColumns()
sal_uInt16 nCols = m_nCols;
m_pColumns = new LwpColumnLayout *[nCols];
- sal_Bool * pWidthCalculated = new sal_Bool[nCols];
+ std::unique_ptr<bool[]> pWidthCalculated( new bool[nCols] );
for(sal_uInt16 i=0;i<nCols; i++)
{
pWidthCalculated[i] = false;
@@ -581,7 +582,6 @@ void LwpTableLayout::RegisterColumns()
auto nColId = pColumnLayout->GetColumnID();
if (nColId >= nCols)
{
- delete [] pWidthCalculated;
throw std::range_error("corrupt LwpTableLayout");
}
m_pColumns[nColId] = pColumnLayout;
@@ -642,7 +642,6 @@ void LwpTableLayout::RegisterColumns()
}
}
}
- delete [] pWidthCalculated;
}
/**
* @short register all row styles