diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-18 14:57:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-19 07:58:31 +0200 |
commit | 8b1a6e68536daee46c8a39ef855e6638df0f07b0 (patch) | |
tree | 086e6f2d4a1da7d2b7b34f932245b57b96b04427 /lotuswordpro | |
parent | clang-tidy readability-misleading-indentation (diff) | |
download | core-8b1a6e68536daee46c8a39ef855e6638df0f07b0.tar.gz core-8b1a6e68536daee46c8a39ef855e6638df0f07b0.zip |
use unique_ptr in LwpGraphicObject::GetGrafData
Change-Id: I19ba8eb5251af3b0c381275a0a18cf8c50944372
Reviewed-on: https://gerrit.libreoffice.org/61941
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwpgrfobj.cxx | 12 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpgrfobj.hxx | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index 61f35d0879e4..6e0069bf98a8 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -355,7 +355,7 @@ std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData() * @param pGrafData the array to store the image data. the pointer need to be deleted outside. * @return the length of the image data. */ -sal_uInt32 LwpGraphicObject::GetGrafData(sal_uInt8*& pGrafData) +sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData) { // create graphic object // if small file, use the compressed stream for BENTO @@ -386,8 +386,8 @@ sal_uInt32 LwpGraphicObject::GetGrafData(sal_uInt8*& pGrafData) // read image data sal_uInt32 nDataLen = pGrafStream->TellEnd(); - pGrafData = new sal_uInt8 [nDataLen]; - pMemGrafStream->ReadBytes(pGrafData, nDataLen); + pGrafData.reset(new sal_uInt8 [nDataLen]); + pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen); delete pMemGrafStream; pMemGrafStream = nullptr; @@ -643,7 +643,7 @@ void LwpGraphicObject::CreateGrafObject() */ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont) { - sal_uInt8* pGrafData = nullptr; + std::unique_ptr<sal_uInt8[]> pGrafData; sal_uInt32 nDataLen = GetGrafData(pGrafData); if(pGrafData) { @@ -687,11 +687,7 @@ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont) pXFPara->Add(pXFNote); pCont->Add(pXFPara); - - delete [] pGrafData; - pGrafData = nullptr; } - } void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight) diff --git a/lotuswordpro/source/filter/lwpgrfobj.hxx b/lotuswordpro/source/filter/lwpgrfobj.hxx index 726d8ec049cc..969e0c0f05d3 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.hxx +++ b/lotuswordpro/source/filter/lwpgrfobj.hxx @@ -119,7 +119,7 @@ public: void CreateGrafObject(); static void GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName); std::vector<sal_uInt8> GetRawGrafData(); - sal_uInt32 GetGrafData(sal_uInt8*& pGrafData); + sal_uInt32 GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData); void GetGrafOrgSize(long& rWidth, long& rHeight) { rWidth = m_Cache.Width; rHeight = m_Cache.Height; } void GetGrafOrgSize(double& rWidth, double& rHeight) override; |