diff options
-rw-r--r-- | compilerplugins/clang/useuniqueptr.cxx | 3 | ||||
-rw-r--r-- | include/package/Deflater.hxx | 3 | ||||
-rw-r--r-- | include/package/Inflater.hxx | 3 | ||||
-rw-r--r-- | package/source/zipapi/Deflater.cxx | 27 | ||||
-rw-r--r-- | package/source/zipapi/Inflater.cxx | 23 |
5 files changed, 31 insertions, 28 deletions
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index 192ae50a4eba..0b5fb2c79aa7 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -42,6 +42,9 @@ public: // this just too clever for me if (fn == SRCDIR "/sc/source/core/tool/chgtrack.cxx") return; + // too clever + if (fn == SRCDIR "/pyuno/source/module/pyuno_runtime.cxx") + return; TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/include/package/Deflater.hxx b/include/package/Deflater.hxx index 9d88997f5be6..2ecb7636ff19 100644 --- a/include/package/Deflater.hxx +++ b/include/package/Deflater.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <package/packagedllapi.hxx> +#include <memory> struct z_stream_s; @@ -35,7 +36,7 @@ class DLLPUBLIC_PACKAGE Deflater final bool bFinish; bool bFinished; sal_Int64 nOffset, nLength; - z_stream* pStream; + std::unique_ptr<z_stream> pStream; void init (sal_Int32 nLevel, bool bNowrap); sal_Int32 doDeflateBytes (css::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength); diff --git a/include/package/Inflater.hxx b/include/package/Inflater.hxx index ebec98734f3f..1e3892f83d75 100644 --- a/include/package/Inflater.hxx +++ b/include/package/Inflater.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <package/packagedllapi.hxx> +#include <memory> struct z_stream_s; @@ -33,7 +34,7 @@ class DLLPUBLIC_PACKAGE Inflater final bool bFinished, bNeedDict; sal_Int32 nOffset, nLength, nLastInflateError; - z_stream* pStream; + std::unique_ptr<z_stream> pStream; css::uno::Sequence < sal_Int8 > sInBuffer; sal_Int32 doInflateBytes (css::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength); diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx index e2f0e7ebd374..d50317357ef1 100644 --- a/package/source/zipapi/Deflater.cxx +++ b/package/source/zipapi/Deflater.cxx @@ -37,20 +37,20 @@ Deflater::~Deflater() } void Deflater::init (sal_Int32 nLevelArg, bool bNowrap) { - pStream = new z_stream; + pStream.reset(new z_stream); /* Memset it to 0...sets zalloc/zfree/opaque to NULL */ - memset (pStream, 0, sizeof(*pStream)); + memset (pStream.get(), 0, sizeof(*pStream)); - switch (deflateInit2(pStream, nLevelArg, Z_DEFLATED, bNowrap? -MAX_WBITS : MAX_WBITS, + switch (deflateInit2(pStream.get(), nLevelArg, Z_DEFLATED, bNowrap? -MAX_WBITS : MAX_WBITS, DEF_MEM_LEVEL, DEFAULT_STRATEGY)) { case Z_OK: break; case Z_MEM_ERROR: - delete pStream; + pStream.reset(); break; case Z_STREAM_ERROR: - delete pStream; + pStream.reset(); break; default: break; @@ -75,9 +75,9 @@ sal_Int32 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int pStream->avail_out = nNewLength; #if !defined Z_PREFIX - nResult = deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH); + nResult = deflate(pStream.get(), bFinish ? Z_FINISH : Z_NO_FLUSH); #else - nResult = z_deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH); + nResult = z_deflate(pStream.get(), bFinish ? Z_FINISH : Z_NO_FLUSH); #endif switch (nResult) { @@ -124,9 +124,9 @@ sal_Int64 Deflater::getTotalOut( ) void Deflater::reset( ) { #if !defined Z_PREFIX - deflateReset(pStream); + deflateReset(pStream.get()); #else - z_deflateReset(pStream); + z_deflateReset(pStream.get()); #endif bFinish = false; bFinished = false; @@ -134,16 +134,15 @@ void Deflater::reset( ) } void Deflater::end( ) { - if (pStream != nullptr) + if (pStream) { #if !defined Z_PREFIX - deflateEnd(pStream); + deflateEnd(pStream.get()); #else - z_deflateEnd(pStream); + z_deflateEnd(pStream.get()); #endif - delete pStream; + pStream.reset(); } - pStream = nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx index a059eb1418de..24a3b23e3156 100644 --- a/package/source/zipapi/Inflater.cxx +++ b/package/source/zipapi/Inflater.cxx @@ -34,20 +34,20 @@ Inflater::Inflater(bool bNoWrap) nLastInflateError(0), pStream(nullptr) { - pStream = new z_stream; + pStream.reset(new z_stream); /* memset to 0 to set zalloc/opaque etc */ - memset (pStream, 0, sizeof(*pStream)); + memset (pStream.get(), 0, sizeof(*pStream)); sal_Int32 nRes; - nRes = inflateInit2(pStream, bNoWrap ? -MAX_WBITS : MAX_WBITS); + nRes = inflateInit2(pStream.get(), bNoWrap ? -MAX_WBITS : MAX_WBITS); switch (nRes) { case Z_OK: break; case Z_MEM_ERROR: - delete pStream; + pStream.reset(); break; case Z_STREAM_ERROR: - delete pStream; + pStream.reset(); break; default: break; @@ -78,16 +78,15 @@ sal_Int32 Inflater::doInflateSegment( Sequence< sal_Int8 >& rBuffer, sal_Int32 n void Inflater::end( ) { - if (pStream != nullptr) + if (pStream) { #if !defined Z_PREFIX - inflateEnd(pStream); + inflateEnd(pStream.get()); #else - z_inflateEnd(pStream); + z_inflateEnd(pStream.get()); #endif - delete pStream; + pStream.reset(); } - pStream = nullptr; } sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength) @@ -106,9 +105,9 @@ sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 > &rBuffer, sal_Int32 n pStream->avail_out = nNewLength; #if !defined Z_PREFIX - sal_Int32 nResult = ::inflate(pStream, Z_PARTIAL_FLUSH); + sal_Int32 nResult = ::inflate(pStream.get(), Z_PARTIAL_FLUSH); #else - sal_Int32 nResult = ::z_inflate(pStream, Z_PARTIAL_FLUSH); + sal_Int32 nResult = ::z_inflate(pStream.get(), Z_PARTIAL_FLUSH); #endif switch (nResult) |