diff options
Diffstat (limited to 'boost/align/detail/align.hpp')
-rw-r--r-- | boost/align/detail/align.hpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/boost/align/detail/align.hpp b/boost/align/detail/align.hpp index e3a90dffda..00be6fd6aa 100644 --- a/boost/align/detail/align.hpp +++ b/boost/align/detail/align.hpp @@ -1,10 +1,10 @@ /* - (c) 2014 Glen Joseph Fernandes - glenjofe at gmail dot com +(c) 2014 Glen Joseph Fernandes +glenjofe at gmail dot com - Distributed under the Boost Software - License, Version 1.0. - http://boost.org/LICENSE_1_0.txt +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt */ #ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP #define BOOST_ALIGN_DETAIL_ALIGN_HPP @@ -15,24 +15,26 @@ #include <cstddef> namespace boost { - namespace alignment { - inline void* align(std::size_t alignment, std::size_t size, - void*& ptr, std::size_t& space) - { - BOOST_ASSERT(detail::is_alignment(alignment)); - std::size_t n = detail::address_t(ptr) & (alignment - 1); - if (n != 0) { - n = alignment - n; - } - void* p = 0; - if (n <= space && size <= space - n) { - p = static_cast<char*>(ptr) + n; - ptr = p; - space -= n; - } - return p; - } +namespace alignment { + +inline void* align(std::size_t alignment, std::size_t size, + void*& ptr, std::size_t& space) +{ + BOOST_ASSERT(detail::is_alignment(alignment)); + std::size_t n = detail::address_t(ptr) & (alignment - 1); + if (n != 0) { + n = alignment - n; + } + void* p = 0; + if (n <= space && size <= space - n) { + p = static_cast<char*>(ptr) + n; + ptr = p; + space -= n; } + return p; } +} /* :alignment */ +} /* :boost */ + #endif |