Kaydet (Commit) b7b77279 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in AutoFormatSwBlob

Change-Id: I0cea421c5306eec66999c58ed8a5c2fa8766d60a
Reviewed-on: https://gerrit.libreoffice.org/56329
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 90f965c3
......@@ -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;
}
};
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment