diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-05 14:52:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-05 17:00:14 +0200 |
commit | ec56174b0c83411b762b0992565e58c1ec4fc3f3 (patch) | |
tree | 039e219726643a3281762af65a3c9ec8c68fada8 /bridges/source | |
parent | 7af38dd4fdaff8ae2ca12e2fe7e2319bcc6bdeba (diff) |
loplugin:useuniqueptr in VtableFactory
Change-Id: I122b6749f148abb48f646bfcd32ef86e2f5fa553
Reviewed-on: https://gerrit.libreoffice.org/78651
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'bridges/source')
-rw-r--r-- | bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx | 8 | ||||
-rw-r--r-- | bridges/source/cpp_uno/shared/vtablefactory.cxx | 10 |
2 files changed, 7 insertions, 11 deletions
diff --git a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx index 39afb083b9bd..bb5f268179a7 100644 --- a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx +++ b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx @@ -100,18 +100,18 @@ com::sun::star::uno::XInterface * CppInterfaceProxy::create( { typelib_typedescription_complete( reinterpret_cast< typelib_TypeDescription ** >(&pTypeDescr)); - bridges::cpp_uno::shared::VtableFactory::Vtables aVtables( + const bridges::cpp_uno::shared::VtableFactory::Vtables& rVtables( getVtableFactory()->getVtables(pTypeDescr)); std::unique_ptr< char[] > pMemory( new char[ sizeof (CppInterfaceProxy) - + (aVtables.count - 1) * sizeof (void **)]); + + (rVtables.count - 1) * sizeof (void **)]); new(pMemory.get()) CppInterfaceProxy(pBridge, pUnoI, pTypeDescr, rOId); CppInterfaceProxy * pProxy = reinterpret_cast< CppInterfaceProxy * >( pMemory.release()); - for (sal_Int32 i = 0; i < aVtables.count; ++i) { + for (sal_Int32 i = 0; i < rVtables.count; ++i) { pProxy->vtables[i] = VtableFactory::mapBlockToVtable( - aVtables.blocks[i].start); + rVtables.blocks[i].start); } return castProxyToInterface(pProxy); } diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx index c71ae52ae14e..70187cbd2fe7 100644 --- a/bridges/source/cpp_uno/shared/vtablefactory.cxx +++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx @@ -186,13 +186,12 @@ VtableFactory::~VtableFactory() { for (sal_Int32 j = 0; j < rEntry.second.count; ++j) { freeBlock(rEntry.second.blocks[j]); } - delete[] rEntry.second.blocks; } } rtl_arena_destroy(m_arena); } -VtableFactory::Vtables VtableFactory::getVtables( +const VtableFactory::Vtables& VtableFactory::getVtables( typelib_InterfaceTypeDescription * type) { OUString name(type->aBase.pTypeName); @@ -204,14 +203,11 @@ VtableFactory::Vtables VtableFactory::getVtables( Vtables vtables; assert(blocks.size() <= SAL_MAX_INT32); vtables.count = static_cast< sal_Int32 >(blocks.size()); - std::unique_ptr< Block[] > guardedBlocks( - new Block[vtables.count]); - vtables.blocks = guardedBlocks.get(); + vtables.blocks.reset(new Block[vtables.count]); for (sal_Int32 j = 0; j < vtables.count; ++j) { vtables.blocks[j] = blocks[j]; } - i = m_map.emplace(name, vtables).first; - guardedBlocks.release(); + i = m_map.emplace(name, std::move(vtables)).first; blocks.unguard(); } return i->second; |