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

loplugin:useuniqueptr in bridges

Change-Id: I7248f8b5031e9659b2a58644952e59cc99d6a2d6
Reviewed-on: https://gerrit.libreoffice.org/58483
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 47eaea7d
......@@ -19,8 +19,6 @@
#include <cppinterfaceproxy.hxx>
#include "guardedarray.hxx"
#include <bridge.hxx>
#include <vtablefactory.hxx>
......@@ -31,6 +29,7 @@
#include <typelib/typedescription.h>
#include <cstddef>
#include <memory>
#include <new>
......@@ -103,7 +102,7 @@ com::sun::star::uno::XInterface * CppInterfaceProxy::create(
reinterpret_cast< typelib_TypeDescription ** >(&pTypeDescr));
bridges::cpp_uno::shared::VtableFactory::Vtables aVtables(
getVtableFactory()->getVtables(pTypeDescr));
bridges::cpp_uno::shared::GuardedArray< char > pMemory(
std::unique_ptr< char[] > pMemory(
new char[
sizeof (CppInterfaceProxy)
+ (aVtables.count - 1) * sizeof (void **)]);
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_SHARED_GUARDEDARRAY_HXX
#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_SHARED_GUARDEDARRAY_HXX
namespace bridges { namespace cpp_uno { namespace shared {
template< typename T > class GuardedArray {
public:
explicit GuardedArray(T * thePointer): pointer(thePointer) {}
~GuardedArray() { delete[] pointer; }
T * get() const { return pointer; }
T * release() { T * p = pointer; pointer = nullptr; return p; }
private:
GuardedArray(GuardedArray &) = delete;
void operator =(GuardedArray) = delete;
T * pointer;
};
} } }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -20,8 +20,6 @@
#include <vtablefactory.hxx>
#include "guardedarray.hxx"
#include <vtables.hxx>
#include <osl/thread.h>
......@@ -34,6 +32,7 @@
#include <sal/types.h>
#include <typelib/typedescription.hxx>
#include <memory>
#include <new>
#include <unordered_map>
#include <vector>
......@@ -204,7 +203,7 @@ VtableFactory::Vtables VtableFactory::getVtables(
Vtables vtables;
assert(blocks.size() <= SAL_MAX_INT32);
vtables.count = static_cast< sal_Int32 >(blocks.size());
bridges::cpp_uno::shared::GuardedArray< Block > guardedBlocks(
std::unique_ptr< Block[] > guardedBlocks(
new Block[vtables.count]);
vtables.blocks = guardedBlocks.get();
for (sal_Int32 j = 0; j < vtables.count; ++j) {
......
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