diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-22 13:08:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-25 15:41:32 +0200 |
commit | b7b772799abe5cf85fb1d7626b8fdcac3ce06dc1 (patch) | |
tree | 2074bdcd4f07f9a5be62769f49d60c9b142a22bb /sc | |
parent | 90f965c3b708185c340bc099334a0ad69a1e00ee (diff) |
loplugin:useuniqueptr in AutoFormatSwBlob
Change-Id: I0cea421c5306eec66999c58ed8a5c2fa8766d60a
Reviewed-on: https://gerrit.libreoffice.org/56329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/autoform.hxx | 11 | ||||
-rw-r--r-- | sc/source/core/tool/autoform.cxx | 6 |
2 files changed, 6 insertions, 11 deletions
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; } |