summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 08:35:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 09:38:40 +0100
commitda2d11d2efb1c0baaa80b9d7052f7c8da5b5bf45 (patch)
treef8c8fd04cdd9fa3dc1654e2693111e12f1f48696 /lotuswordpro
parent6256797dacfafaa573a67643440a3fe4e8128dca (diff)
use unique_ptr in BenOpenContainer
Change-Id: Idc9d728e711f70cc11974020aa507552f31d4c9c Reviewed-on: https://gerrit.libreoffice.org/65919 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/bencont.cxx7
-rw-r--r--lotuswordpro/source/filter/bento.hxx3
-rw-r--r--lotuswordpro/source/filter/lwpfilter.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.cxx13
4 files changed, 10 insertions, 17 deletions
diff --git a/lotuswordpro/source/filter/bencont.cxx b/lotuswordpro/source/filter/bencont.cxx
index 06be40c8a614..ceed08c55020 100644
--- a/lotuswordpro/source/filter/bencont.cxx
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -70,7 +70,7 @@ const char gsBenMagicBytes[] = BEN_MAGIC_BYTES;
* @param pointer to pointer of Bento Container object
* @return error code
*/
-sal_uLong BenOpenContainer(LwpSvStream * pStream, LtcBenContainer ** ppContainer)
+sal_uLong BenOpenContainer(LwpSvStream * pStream, std::unique_ptr<LtcBenContainer>* ppContainer)
{
*ppContainer = nullptr;
@@ -79,14 +79,13 @@ sal_uLong BenOpenContainer(LwpSvStream * pStream, LtcBenContainer ** ppContainer
return BenErr_ContainerWithNoObjects;
}
- LtcBenContainer * pContainer = new LtcBenContainer(pStream);
+ std::unique_ptr<LtcBenContainer> pContainer(new LtcBenContainer(pStream));
if (pContainer->Open() != BenErr_OK) // delete two inputs
{
- delete pContainer;
return BenErr_InvalidTOC;
}
- *ppContainer = pContainer;
+ *ppContainer = std::move(pContainer);
return BenErr_OK;
}
diff --git a/lotuswordpro/source/filter/bento.hxx b/lotuswordpro/source/filter/bento.hxx
index 4b294183a8eb..f437ce9bdbec 100644
--- a/lotuswordpro/source/filter/bento.hxx
+++ b/lotuswordpro/source/filter/bento.hxx
@@ -59,6 +59,7 @@
#include <sal/config.h>
#include <cstring>
+#include <memory>
#include <string>
#include <vector>
#include <lwpsvstream.hxx>
@@ -136,7 +137,7 @@ typedef sal_uInt32 BenContainerPos;
typedef sal_uInt32 BenObjectID;
typedef sal_uInt32 BenGeneration;
-sal_uLong BenOpenContainer(LwpSvStream * pStream, LtcBenContainer ** ppContainer);
+sal_uLong BenOpenContainer(LwpSvStream * pStream, std::unique_ptr<LtcBenContainer>* ppContainer);
class CBenIDListElmt : public CUtListElmt
{
diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
index 5dbaf0f29c03..4e743eb4da0f 100644
--- a/lotuswordpro/source/filter/lwpfilter.cxx
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -109,9 +109,7 @@ static bool Decompress(SvStream *pCompressed, SvStream * & pOutDecompressed)
std::unique_ptr<LwpSvStream> aLwpStream(new LwpSvStream(pCompressed));
std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
{
- OpenStormBento::LtcBenContainer* pTmp(nullptr);
- sal_uLong ulRet = BenOpenContainer(aLwpStream.get(), &pTmp);
- pBentoContainer.reset(pTmp);
+ sal_uLong ulRet = BenOpenContainer(aLwpStream.get(), &pBentoContainer);
if (ulRet != BenErr_OK)
return false;
}
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index 6e0069bf98a8..1d21c9a3d4c8 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -286,7 +286,7 @@ void LwpGraphicObject::CreateDrawObjects()
// if small file, use the compressed stream for BENTO
LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
- OpenStormBento::LtcBenContainer* pBentoContainer;
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
if (ulRet != OpenStormBento::BenErr_OK)
return;
@@ -334,9 +334,7 @@ std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData()
std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
{
- OpenStormBento::LtcBenContainer* pTmp(nullptr);
- sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pTmp);
- pBentoContainer.reset(pTmp);
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
if (ulRet != OpenStormBento::BenErr_OK)
return aGrafData;
}
@@ -361,7 +359,7 @@ sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData
// if small file, use the compressed stream for BENTO
LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
- OpenStormBento::LtcBenContainer* pBentoContainer;
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
if (ulRet != OpenStormBento::BenErr_OK)
return 0;
@@ -379,7 +377,7 @@ sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData
// get bento stream by the name
pGrafStream = pBentoContainer->FindValueStreamWithPropertyName(sDName);
- SvMemoryStream* pMemGrafStream = static_cast<SvMemoryStream*>(pGrafStream);
+ std::unique_ptr<SvMemoryStream> pMemGrafStream(static_cast<SvMemoryStream*>(pGrafStream));
if (pMemGrafStream)
{
@@ -389,9 +387,6 @@ sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData
pGrafData.reset(new sal_uInt8 [nDataLen]);
pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen);
- delete pMemGrafStream;
- pMemGrafStream = nullptr;
-
return nDataLen;
}