diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 14:46:38 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-05 08:17:11 -0500 |
commit | 9ca19666511b1d44ba554a70cbbc0c8e2db844c6 (patch) | |
tree | 39a0bd694d2f1cf5d5a67082b85717e5bb2cbef0 /registry | |
parent | 6346e8c08e789e6aa4f2041fab97ba14419dedd4 (diff) |
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated
and deleted inside a single local block, and the delete happening at the
end of the block
Reviewed-on: https://gerrit.libreoffice.org/33749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0)
Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
(cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e)
Diffstat (limited to 'registry')
-rw-r--r-- | registry/source/reflwrit.cxx | 4 | ||||
-rw-r--r-- | registry/source/regimpl.cxx | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx index 59e712f5a966..c2b5f338e310 100644 --- a/registry/source/reflwrit.cxx +++ b/registry/source/reflwrit.cxx @@ -892,7 +892,7 @@ void TypeWriter::createBlop() if (m_methodCount) { - sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount]; + std::unique_ptr<sal_uInt16[]> pMethodEntrySize( new sal_uInt16[m_methodCount] ); sal_uInt16 cpIndexName = 0; sal_uInt16 cpIndexReturn = 0; sal_uInt16 cpIndexDoku2 = 0; @@ -1000,8 +1000,6 @@ void TypeWriter::createBlop() cpIndexName = 0; } } - - delete[] pMethodEntrySize; } // reference blop diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 0655a4642c43..ba49ad9f959b 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -1484,12 +1484,11 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ sal::static_int_cast< unsigned long >(valueSize)); fprintf(stdout, "%s Data = ", indent); - sal_Unicode* value = new sal_Unicode[size]; - readString(pBuffer, value, size); + std::unique_ptr<sal_Unicode[]> value(new sal_Unicode[size]); + readString(pBuffer, value.get(), size); - OString uStr = OUStringToOString(value, RTL_TEXTENCODING_UTF8); + OString uStr = OUStringToOString(value.get(), RTL_TEXTENCODING_UTF8); fprintf(stdout, "L\"%s\"\n", uStr.getStr()); - delete[] value; } break; case RegValueType::BINARY: |