diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-23 15:03:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-23 15:58:38 +0100 |
commit | 5fd05b2d4a61af0e72cf75f465c4f6ad7b2f4cc9 (patch) | |
tree | 8a031c77cb27fdcd0c79eda73aa447db304042ba /unoxml | |
parent | f429fa2ea1daa22b7df82cb4c3a5028cd840489a (diff) |
simplify NodeArray code
no need to use shared_ptr here
Change-Id: Ib40929c4378e110eb42261df36b4add969416cb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87269
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unoxml')
-rw-r--r-- | unoxml/source/rdf/librdf_repository.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index 39db47b51b99..68ba3135512f 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -634,17 +634,20 @@ librdf_QuerySelectResult::hasMoreElements() return !librdf_query_results_finished(m_pQueryResult.get()); } -class NodeArrayDeleter +struct NodeArray { - const int m_Count; + int m_Count; + std::unique_ptr<librdf_node*[]> m_pNodes; -public: - explicit NodeArrayDeleter(int i_Count) : m_Count(i_Count) { } + NodeArray(int cnt) : m_Count(cnt), m_pNodes(new librdf_node*[cnt]) + { + for (int i = 0; i < cnt; ++i) + m_pNodes[i] = nullptr; + } - void operator() (librdf_node** io_pArray) const throw () + ~NodeArray() throw () { - std::for_each(io_pArray, io_pArray + m_Count, safe_librdf_free_node); - delete[] io_pArray; + std::for_each(m_pNodes.get(), m_pNodes.get() + m_Count, safe_librdf_free_node); } }; @@ -657,13 +660,9 @@ librdf_QuerySelectResult::nextElement() } sal_Int32 count(m_BindingNames.getLength()); OSL_ENSURE(count >= 0, "negative length?"); - std::shared_ptr<librdf_node*> const pNodes(new librdf_node*[count], - NodeArrayDeleter(count)); - for (int i = 0; i < count; ++i) { - pNodes.get()[i] = nullptr; - } + NodeArray aNodes(count); if (librdf_query_results_get_bindings(m_pQueryResult.get(), nullptr, - pNodes.get())) + aNodes.m_pNodes.get())) { rdf::QueryException e( "librdf_QuerySelectResult::nextElement: " @@ -675,7 +674,7 @@ librdf_QuerySelectResult::nextElement() } uno::Sequence< uno::Reference< rdf::XNode > > ret(count); for (int i = 0; i < count; ++i) { - ret[i] = m_xRep->getTypeConverter().convertToXNode(pNodes.get()[i]); + ret[i] = m_xRep->getTypeConverter().convertToXNode(aNodes.m_pNodes[i]); } // NB: this will invalidate current item. librdf_query_results_next(m_pQueryResult.get()); |