vcl/source/filter/webp/reader.cxx |    6 ++----
 vcl/source/filter/webp/writer.cxx |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

New commits:
commit 5dfafa8b1450d6952d7d8d87eb6b0d01c7afcee2
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Jan 27 10:53:06 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Feb 1 19:36:17 2022 +0100

    use comphelper::ScopeGuard instead of (ab)using std::unique_ptr
    
    Change-Id: Ie948064ea09b6fe415b28ec4165883bc78136619
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129279
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/source/filter/webp/reader.cxx 
b/vcl/source/filter/webp/reader.cxx
index e8c885053965..5ec8fa4870c2 100644
--- a/vcl/source/filter/webp/reader.cxx
+++ b/vcl/source/filter/webp/reader.cxx
@@ -26,6 +26,7 @@
 #include <sal/log.hxx>
 #include <unotools/configmgr.hxx>
 #include <svdata.hxx>
+#include <comphelper/scopeguard.hxx>
 
 #include <webp/decode.h>
 
@@ -59,10 +60,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic)
         SAL_WARN("vcl.filter.webp", "WebPInitDecoderConfig() failed");
         return false;
     }
-    // This unique_ptr is here just to ensure WebPFreeDecBuffer() is called at 
the end,
-    // it doesn't actually own the data as such.
-    std::unique_ptr<WebPDecBuffer, decltype(&WebPFreeDecBuffer)> 
freeBuffer(&config.output,
-                                                                            
WebPFreeDecBuffer);
+    comphelper::ScopeGuard freeBuffer([&config]() { 
WebPFreeDecBuffer(&config.output); });
     std::vector<uint8_t> data;
     if (!readWebpInfo(stream, data, config.input))
         return false;
diff --git a/vcl/source/filter/webp/writer.cxx 
b/vcl/source/filter/webp/writer.cxx
index 32da25e93ca3..b1ac654d858a 100644
--- a/vcl/source/filter/webp/writer.cxx
+++ b/vcl/source/filter/webp/writer.cxx
@@ -17,11 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <memory>
 #include <vcl/graph.hxx>
 #include <tools/stream.hxx>
 #include <filter/WebpWriter.hxx>
 #include <vcl/BitmapReadAccess.hxx>
+#include <comphelper/scopeguard.hxx>
 #include <sal/log.hxx>
 
 #include <webp/encode.h>
@@ -87,9 +87,7 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& 
bitmapEx, bool lossless
     picture.width = width;
     picture.height = height;
     picture.use_argb = lossless ? 1 : 0; // libwebp recommends argb only for 
lossless
-    // This unique_ptr is here just to ensure WebPPictureFree() is called at 
the end,
-    // it doesn't actually own the data as such.
-    std::unique_ptr<WebPPicture, decltype(&WebPPictureFree)> 
freePicture(&picture, WebPPictureFree);
+    comphelper::ScopeGuard freePicture([&picture]() { 
WebPPictureFree(&picture); });
 
     // Apparently libwebp needs the entire image data at once in WebPPicture,
     // so allocate it and copy there.

Reply via email to