diff options
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/minimizer/pppoptimizertoken.cxx | 6 | ||||
-rw-r--r-- | sdext/source/pdfimport/wrapper/wrapper.cxx | 7 | ||||
-rw-r--r-- | sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 8 |
3 files changed, 9 insertions, 12 deletions
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index d24b35e2998d..d99c49bfb15b 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -23,6 +23,7 @@ #include <sal/macros.h> #include <string.h> #include <unordered_map> +#include <memory> typedef std::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap; static TypeNameHashMap* pHashMap = nullptr; @@ -172,12 +173,11 @@ PPPOptimizerTokenEnum TKGet( const OUString& rToken ) } PPPOptimizerTokenEnum eRetValue = TK_NotFound; int i, nLen = rToken.getLength(); - char* pBuf = new char[ nLen + 1 ]; + std::unique_ptr<char[]> pBuf(new char[ nLen + 1 ]); for ( i = 0; i < nLen; i++ ) pBuf[ i ] = (char)rToken[ i ]; pBuf[ i ] = 0; - TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) ); - delete[] pBuf; + TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf.get() ) ); if ( aHashIter != pHashMap->end() ) eRetValue = (*aHashIter).second; return eRetValue; diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index 5e1584e4cfba..74e17f87c118 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -203,10 +203,10 @@ namespace { const size_t nOrigLen(sal::static_int_cast<size_t>(i_rStr.getLength())); const sal_Char* const pOrig(i_rStr.getStr()); - sal_Char* const pBuffer(new sal_Char[nOrigLen + 1]); + std::unique_ptr<sal_Char[]> pBuffer(new sal_Char[nOrigLen + 1]); const sal_Char* pRead(pOrig); - sal_Char* pWrite(pBuffer); + sal_Char* pWrite(pBuffer.get()); const sal_Char* pCur(pOrig); while ((pCur = strchr(pCur, '\\')) != nullptr) { @@ -237,8 +237,7 @@ namespace } *pWrite = '\0'; - OString aResult(pBuffer); - delete[] pBuffer; + OString aResult(pBuffer.get()); return aResult; } diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index c81adc331dbf..b67d6613ba42 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -26,6 +26,7 @@ #include <math.h> #include <boost/shared_array.hpp> +#include <memory> #if defined _MSC_VER #pragma warning(push, 1) @@ -309,11 +310,11 @@ void writePpm_( OutputBuffer& o_rOutputBuf, // initialize stream Guchar *p; GfxRGB rgb; - ImageStream* imgStr = + std::unique_ptr<ImageStream> imgStr( new ImageStream(str, width, colorMap->getNumPixelComps(), - colorMap->getBits()); + colorMap->getBits())); imgStr->reset(); for( int y=0; y<height; ++y) @@ -329,9 +330,6 @@ void writePpm_( OutputBuffer& o_rOutputBuf, p +=colorMap->getNumPixelComps(); } } - - delete imgStr; - } // call this only for 1 bit image streams ! |