diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 14:46:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-01 12:15:22 +0000 |
commit | 2489000d3fd66319a8355fd4e37cfdfda47296d0 (patch) | |
tree | caad79e7b5bec3863604b20190b682c0d73d2b25 /lotuswordpro/source | |
parent | gpg4libre: Support building --with-system-gpgme (Linux only so far) (diff) | |
download | core-2489000d3fd66319a8355fd4e37cfdfda47296d0.tar.gz core-2489000d3fd66319a8355fd4e37cfdfda47296d0.zip |
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
Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
Reviewed-on: https://gerrit.libreoffice.org/33749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r-- | lotuswordpro/source/filter/lwpgrfobj.cxx | 5 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpidxmgr.cxx | 19 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwppara.cxx | 4 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwptablelayout.cxx | 5 |
4 files changed, 14 insertions, 19 deletions
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index 882f7d2b31e1..b28a52eb1722 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -698,13 +698,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 8d02521b0585..3b6b3a707ba4 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 |