diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-10 10:27:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-12 08:56:42 +0200 |
commit | e75baaa5dfffd96da55b892dd26ffec37ad5080c (patch) | |
tree | 805681ee246900f1f1f725a569a1c92723738015 /lotuswordpro | |
parent | 7e69b971a5453e7092e5c3ef5ca197261227479e (diff) |
loplugin:useuniqueptr in lotuswordpro
Change-Id: Ib34984180cea7143b6595decba785f1b55d15e2c
Reviewed-on: https://gerrit.libreoffice.org/60336
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwpbackgroundstuff.cxx | 9 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpdocdata.cxx | 8 | ||||
-rw-r--r-- | lotuswordpro/source/filter/xfilter/xfbase64.cxx | 17 |
3 files changed, 16 insertions, 18 deletions
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx index 4bce3d669545..b139682f46e9 100644 --- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx +++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx @@ -147,15 +147,14 @@ std::unique_ptr<XFBGImage> LwpBackgroundStuff::GetFillPattern() aXOBitmap.Array2Bitmap(); WriteDIB(aXOBitmap.GetBitmap(), aPicMemStream); sal_uInt32 nSize = aPicMemStream.GetEndOfData(); - sal_uInt8* pImageBuff = new sal_uInt8 [nSize]; - memcpy(pImageBuff, aPicMemStream.GetData(), nSize); + std::unique_ptr<sal_uInt8[]> pImageBuff(new sal_uInt8 [nSize]); + memcpy(pImageBuff.get(), aPicMemStream.GetData(), nSize); // create XFBGImage object. std::unique_ptr<XFBGImage> xXFBGImage(new XFBGImage); - xXFBGImage->SetImageData(pImageBuff, nSize); + xXFBGImage->SetImageData(pImageBuff.get(), nSize); - delete [] pImageBuff; - pImageBuff = nullptr; + pImageBuff.reset(); xXFBGImage->SetRepeate(); diff --git a/lotuswordpro/source/filter/lwpdocdata.cxx b/lotuswordpro/source/filter/lwpdocdata.cxx index 55d43f0e016b..e887515248ad 100644 --- a/lotuswordpro/source/filter/lwpdocdata.cxx +++ b/lotuswordpro/source/filter/lwpdocdata.cxx @@ -116,8 +116,8 @@ void LwpDocData::Read() //EditorList m_DocInfo.nNumEditedBy = m_pObjStrm->QuickReaduInt16(); - LwpAtomHolder* pCDLNList = new LwpAtomHolder[m_DocInfo.nNumEditedBy]; - LwpAtomHolder* pEditorList = new LwpAtomHolder[m_DocInfo.nNumEditedBy]; + std::unique_ptr<LwpAtomHolder[]> pCDLNList(new LwpAtomHolder[m_DocInfo.nNumEditedBy]); + std::unique_ptr<LwpAtomHolder[]> pEditorList(new LwpAtomHolder[m_DocInfo.nNumEditedBy]); sal_uInt16 i = 0; for ( i = 0; i < m_DocInfo.nNumEditedBy; i++) { @@ -131,8 +131,8 @@ void LwpDocData::Read() m_pObjStrm->SkipExtra(); - delete [] pCDLNList; - delete [] pEditorList; + pCDLNList.reset(); + pEditorList.reset(); //doc control //cGreeting diff --git a/lotuswordpro/source/filter/xfilter/xfbase64.cxx b/lotuswordpro/source/filter/xfilter/xfbase64.cxx index 9e3787f2bab7..0a388f7b6a47 100644 --- a/lotuswordpro/source/filter/xfilter/xfbase64.cxx +++ b/lotuswordpro/source/filter/xfilter/xfbase64.cxx @@ -58,6 +58,7 @@ * Base64 tool. ************************************************************************/ #include <string.h> +#include <memory> #include "xfbase64.hxx" const sal_Char aBase64EncodeTable[] = @@ -95,7 +96,7 @@ inline void Encode_(const sal_uInt8 *src, sal_Char* dest) */ OUString XFBase64::Encode(sal_uInt8 const *buf, sal_Int32 len) { - sal_Char *buffer; + std::unique_ptr<sal_Char[]> buffer; sal_Int32 nNeeded; sal_Int32 cycles = len/3; sal_Int32 remain = len%3; @@ -104,31 +105,29 @@ OUString XFBase64::Encode(sal_uInt8 const *buf, sal_Int32 len) nNeeded = cycles*4; else nNeeded = (cycles+1)*4; - buffer = new sal_Char[nNeeded+1]; + buffer.reset(new sal_Char[nNeeded+1]); - memset(buffer, 0, nNeeded+1); + memset(buffer.get(), 0, nNeeded+1); for( sal_Int32 i=0; i<cycles; i++ ) - Encode_(buf+i*3,buffer+i*4); + Encode_(buf+i*3,buffer.get()+i*4); sal_uInt8 last[3]; if( remain == 1 ) { last[0] = buf[len-1]; last[1] = last[2] = 0; - Encode_(last,buffer+nNeeded+1-5); + Encode_(last,buffer.get()+nNeeded+1-5); } else if( remain == 2 ) { last[0] = buf[len-2]; last[1] = buf[len-1]; last[2] = 0; - Encode_(last,buffer+nNeeded+1-5); + Encode_(last,buffer.get()+nNeeded+1-5); } - OUString str = OUString::createFromAscii(buffer); - delete[] buffer; - + OUString str = OUString::createFromAscii(buffer.get()); return str; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |