summaryrefslogtreecommitdiff
path: root/registry
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-04 09:49:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-05 09:28:42 +0200
commit06951f8c14d6b8861af58bbb6b7f61a00b378a1c (patch)
treed4c2e5fb29364ff29fc4fc55f449b8a2d41f4b1f /registry
parent80f990b8e3d05e47e041685a7811f1352d03ad4d (diff)
loplugin:useuniqueptr in TypeWriter::createBlop
Change-Id: I33ce7786430d9a8c7cbc835fc5ca381fe5ab8b8f Reviewed-on: https://gerrit.libreoffice.org/59993 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'registry')
-rw-r--r--registry/source/reflwrit.cxx28
1 files changed, 12 insertions, 16 deletions
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index dc3e2a15b603..c85113293308 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -718,9 +718,9 @@ void TypeWriter::createBlop()
{
//TODO: Fix memory leaks that occur when std::bad_alloc is thrown
- sal_uInt8* pBlopFields = nullptr;
- sal_uInt8* pBlopMethods = nullptr;
- sal_uInt8* pBlopReferences = nullptr;
+ std::unique_ptr<sal_uInt8[]> pBlopFields;
+ std::unique_ptr<sal_uInt8[]> pBlopMethods;
+ std::unique_ptr<sal_uInt8[]> pBlopReferences;
sal_uInt8* pBuffer = nullptr;
sal_uInt32 blopFieldsSize = 0;
sal_uInt32 blopMethodsSize = 0;
@@ -797,8 +797,8 @@ void TypeWriter::createBlop()
blopSize += blopFieldsSize;
- pBlopFields = new sal_uInt8[blopFieldsSize];
- pBuffer = pBlopFields;
+ pBlopFields.reset(new sal_uInt8[blopFieldsSize]);
+ pBuffer = pBlopFields.get();
pBuffer += writeUINT16(pBuffer, BLOP_FIELD_N_ENTRIES);
@@ -878,11 +878,11 @@ void TypeWriter::createBlop()
blopMethodsSize += pMethodEntrySize[i];
}
- pBlopMethods = new sal_uInt8[blopMethodsSize];
+ pBlopMethods.reset(new sal_uInt8[blopMethodsSize]);
blopSize += blopMethodsSize;
- pBuffer = pBlopMethods;
+ pBuffer = pBlopMethods.get();
pBuffer += writeUINT16(pBuffer, BLOP_METHOD_N_ENTRIES);
pBuffer += writeUINT16(pBuffer, BLOP_PARAM_N_ENTRIES );
@@ -981,8 +981,8 @@ void TypeWriter::createBlop()
blopSize += blopReferenceSize;
- pBlopReferences = new sal_uInt8[blopReferenceSize];
- pBuffer = pBlopReferences;
+ pBlopReferences.reset(new sal_uInt8[blopReferenceSize]);
+ pBuffer = pBlopReferences.get();
pBuffer += writeUINT16(pBuffer, BLOP_REFERENCE_N_ENTRIES);
@@ -1088,17 +1088,13 @@ void TypeWriter::createBlop()
};
// write fields
- writeList(m_fieldCount, pBlopFields, blopFieldsSize);
+ writeList(m_fieldCount, pBlopFields.get(), blopFieldsSize);
// write methods
- writeList(m_methodCount, pBlopMethods, blopMethodsSize);
+ writeList(m_methodCount, pBlopMethods.get(), blopMethodsSize);
// write references
- writeList(m_referenceCount, pBlopReferences, blopReferenceSize);
-
- delete[] pBlopFields;
- delete[] pBlopMethods;
- delete[] pBlopReferences;
+ writeList(m_referenceCount, pBlopReferences.get(), blopReferenceSize);
m_blop.reset( blop );
m_blopSize = blopSize;