From 4138e6be1d73311d2b0d056c841d67dfeca8404a Mon Sep 17 00:00:00 2001 From: Jackie Kay Date: Fri, 23 Oct 2015 11:41:45 -0700 Subject: [PATCH] Use allocate_shared --- rclcpp/include/rclcpp/message_memory_strategy.hpp | 5 +---- .../include/rclcpp/strategies/allocator_memory_strategy.hpp | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/rclcpp/include/rclcpp/message_memory_strategy.hpp b/rclcpp/include/rclcpp/message_memory_strategy.hpp index e88c077..9860303 100644 --- a/rclcpp/include/rclcpp/message_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/message_memory_strategy.hpp @@ -58,10 +58,7 @@ public: // \return Shared pointer to the new message. virtual std::shared_ptr borrow_message() { - auto ptr = MessageAllocTraits::allocate(*message_allocator_.get(), 1); - MessageAllocTraits::construct(*message_allocator_.get(), ptr); - return std::shared_ptr(ptr, message_deleter_); - //return std::allocate_shared(*message_allocator_); + return std::allocate_shared(*message_allocator_.get()); } /// Release ownership of the message, which will deallocate it if it has no more owners. diff --git a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp index 90c6dee..a6ebfc3 100644 --- a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp @@ -137,10 +137,7 @@ public: // \return Shared pointer to the fresh executable. virtual executor::AnyExecutable::SharedPtr instantiate_next_executable() { - //return std::make_shared(); - auto ptr = ExecAllocTraits::allocate(*executable_allocator_.get(), 1); - ExecAllocTraits::construct(*executable_allocator_.get(), ptr); - return std::shared_ptr(ptr, executable_deleter_); + return std::allocate_shared(*executable_allocator_.get()); } /// Implementation of a general-purpose allocation function. @@ -190,7 +187,6 @@ public: private: std::shared_ptr executable_allocator_; - ExecDeleter executable_deleter_; std::shared_ptr allocator_; };