From f6f0de0e38fdd50ba12cbebf669e1ba0dfac8fa5 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 24 Sep 2014 13:17:55 +0200 Subject: [PATCH] pimpl OSRM lib with std::unique_ptr --- Library/OSRM.h | 4 +++- Library/OSRM_impl.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/OSRM.h b/Library/OSRM.h index 16b9977cc..5e3480249 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -30,6 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include + class OSRM_impl; struct RouteParameters; @@ -41,7 +43,7 @@ class Reply; class OSRM { private: - OSRM_impl *OSRM_pimpl_; + std::unique_ptr OSRM_pimpl_; public: explicit OSRM(const ServerPaths &paths, const bool use_shared_memory = false); diff --git a/Library/OSRM_impl.cpp b/Library/OSRM_impl.cpp index 5c20b5aef..f18c812ef 100644 --- a/Library/OSRM_impl.cpp +++ b/Library/OSRM_impl.cpp @@ -45,6 +45,7 @@ namespace boost { namespace interprocess { class named_mutex; } } #include "../Server/DataStructures/InternalDataFacade.h" #include "../Server/DataStructures/SharedBarriers.h" #include "../Server/DataStructures/SharedDataFacade.h" +#include "../Util/make_unique.hpp" #include "../Util/SimpleLogger.h" #include @@ -155,11 +156,11 @@ void OSRM_impl::RunQuery(RouteParameters &route_parameters, http::Reply &reply) // proxy code for compilation firewall OSRM::OSRM(const ServerPaths &paths, const bool use_shared_memory) - : OSRM_pimpl_(new OSRM_impl(paths, use_shared_memory)) + : OSRM_pimpl_(osrm::make_unique(paths, use_shared_memory)) { } -OSRM::~OSRM() { delete OSRM_pimpl_; } +OSRM::~OSRM() { OSRM_pimpl_.reset(); } void OSRM::RunQuery(RouteParameters &route_parameters, http::Reply &reply) {