[Libreoffice-commits] core.git: sc/inc sc/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Jun 25 13:41:55 UTC 2018


 sc/inc/autoform.hxx              |   11 +++--------
 sc/source/core/tool/autoform.cxx |    6 +++---
 2 files changed, 6 insertions(+), 11 deletions(-)

New commits:
commit b7b772799abe5cf85fb1d7626b8fdcac3ce06dc1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jun 22 13:08:33 2018 +0200

    loplugin:useuniqueptr in AutoFormatSwBlob
    
    Change-Id: I0cea421c5306eec66999c58ed8a5c2fa8766d60a
    Reviewed-on: https://gerrit.libreoffice.org/56329
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index b1559dc264de..18f2bb6ee9a4 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -68,23 +68,18 @@ blobs to avoid needlessly complicating the Calc logic.
 */
 struct AutoFormatSwBlob
 {
-    sal_uInt8 *pData;
+    std::unique_ptr<sal_uInt8[]> pData;
     std::size_t size;
 
-    AutoFormatSwBlob() : pData(nullptr), size(0)
+    AutoFormatSwBlob() : size(0)
     {
     }
     AutoFormatSwBlob(const AutoFormatSwBlob&) = delete;
     const AutoFormatSwBlob& operator=(const AutoFormatSwBlob&) = delete;
-    ~AutoFormatSwBlob()
-    {
-        Reset();
-    }
 
     void Reset()
     {
-        delete[] pData;
-        pData = nullptr;
+        pData.reset();
         size = 0;
     }
 };
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 939e6e0af4b9..0a5e7f48c70c 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -97,9 +97,9 @@ namespace
         // since it (naturally) doesn't have any writer-specific data to write.
         if (blobSize)
         {
-            blob.pData = new sal_uInt8[blobSize];
+            blob.pData.reset(new sal_uInt8[blobSize]);
             blob.size = static_cast<std::size_t>(blobSize);
-            stream.ReadBytes(blob.pData, blob.size);
+            stream.ReadBytes(blob.pData.get(), blob.size);
         }
 
         return stream;
@@ -111,7 +111,7 @@ namespace
         const sal_uInt64 endOfBlob = stream.Tell() + sizeof(sal_uInt64) + blob.size;
         stream.WriteUInt64( endOfBlob );
         if (blob.size)
-            stream.WriteBytes(blob.pData, blob.size);
+            stream.WriteBytes(blob.pData.get(), blob.size);
 
         return stream;
     }


More information about the Libreoffice-commits mailing list