From 2489000d3fd66319a8355fd4e37cfdfda47296d0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 31 Jan 2017 14:46:38 +0200 Subject: 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 Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins Reviewed-by: Noel Grandin --- registry/source/reflwrit.cxx | 4 +--- registry/source/regimpl.cxx | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'registry') diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx index e0b52b08c17c..ced57265ddd9 100644 --- a/registry/source/reflwrit.cxx +++ b/registry/source/reflwrit.cxx @@ -877,7 +877,7 @@ void TypeWriter::createBlop() if (m_methodCount) { - sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount]; + std::unique_ptr pMethodEntrySize( new sal_uInt16[m_methodCount] ); sal_uInt16 cpIndexName = 0; sal_uInt16 cpIndexReturn = 0; sal_uInt16 cpIndexDoku2 = 0; @@ -985,8 +985,6 @@ void TypeWriter::createBlop() cpIndexName = 0; } } - - delete[] pMethodEntrySize; } // reference blop diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 6f684e12ef83..c6ea42c6169a 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -1483,12 +1483,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 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: -- cgit