diff --git a/include/boost/smart_ptr/detail/array_allocator.hpp b/include/boost/smart_ptr/detail/array_allocator.hpp index aea824c..069f844 100644 --- a/include/boost/smart_ptr/detail/array_allocator.hpp +++ b/include/boost/smart_ptr/detail/array_allocator.hpp @@ -9,9 +9,9 @@ #ifndef BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP #define BOOST_SMART_PTR_DETAIL_ARRAY_ALLOCATOR_HPP +#include #include #include -#include #include namespace boost { @@ -125,20 +125,17 @@ namespace boost { data(other.data) { } - pointer allocate(size_type count, const_void_pointer hint = 0) { + pointer allocate(size_type count, const_void_pointer = 0) { enum { M = boost::alignment_of::value }; std::size_t n1 = count * sizeof(value_type); - std::size_t n2 = data.size * sizeof(type) + M; + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; CA ca(allocator()); -#if !defined(BOOST_NO_CXX11_ALLOCATOR) - void* p1 = CT::allocate(ca, n1 + n2, hint); -#else - void* p1 = ca.allocate(n1 + n2, hint); -#endif + void* p1 = ca.allocate(n1 + n3); void* p2 = static_cast(p1) + n1; - p2 = sp_align(M, p2); + (void)boost::alignment::align(M, n2, p2, n3); *data.result = static_cast(p2); return static_cast(p1); } @@ -243,10 +240,11 @@ namespace boost { M = boost::alignment_of::value }; std::size_t n1 = count * sizeof(Y); - std::size_t n2 = data.size * sizeof(type) + M; - void* p1 = ::operator new(n1 + n2); + std::size_t n2 = data.size * sizeof(type); + std::size_t n3 = n2 + M; + void* p1 = ::operator new(n1 + n3); void* p2 = static_cast(p1) + n1; - p2 = sp_align(M, p2); + (void)boost::alignment::align(M, n2, p2, n3); *data.result = static_cast(p2); return static_cast(p1); } @@ -278,6 +276,7 @@ namespace boost { } void destroy(pointer memory) { + (void)memory; memory->~Y(); } #endif diff --git a/include/boost/smart_ptr/detail/sp_align.hpp b/include/boost/smart_ptr/detail/sp_align.hpp deleted file mode 100644 index 5a616ee..0000000 --- a/include/boost/smart_ptr/detail/sp_align.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Glen Joseph Fernandes - * glenfe at live dot com - * - * Distributed under the Boost Software License, - * Version 1.0. (See accompanying file LICENSE_1_0.txt - * or copy at http://boost.org/LICENSE_1_0.txt) - */ -#ifndef BOOST_SMART_PTR_DETAIL_SP_ALIGN_HPP -#define BOOST_SMART_PTR_DETAIL_SP_ALIGN_HPP - -#include - -namespace boost { - namespace detail { - inline void* sp_align(std::size_t alignment, void* ptr) { - std::size_t n1 = (std::size_t)ptr % alignment; - if (n1 != 0) { - ptr = (char*)ptr + alignment - n1; - } - return ptr; - } - } -} - -#endif