1// 2// impl/handler_alloc_hook.ipp 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4// 5// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6// 7// Distributed under the Boost Software License, Version 1.0. (See accompanying 8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9// 10 11#ifndef BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP 12#define BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP 13 14#if defined(_MSC_VER) && (_MSC_VER >= 1200) 15# pragma once 16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 18#include <boost/asio/detail/config.hpp> 19#include <boost/asio/detail/thread_context.hpp> 20#include <boost/asio/detail/thread_info_base.hpp> 21#include <boost/asio/handler_alloc_hook.hpp> 22 23#include <boost/asio/detail/push_options.hpp> 24 25namespace boost { 26namespace asio { 27 28asio_handler_allocate_is_deprecated 29asio_handler_allocate(std::size_t size, ...) 30{ 31#if defined(BOOST_ASIO_NO_DEPRECATED) 32 (void)size; 33 return asio_handler_allocate_is_no_longer_used(); 34#elif !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 35 return detail::thread_info_base::allocate( 36 detail::thread_context::top_of_thread_call_stack(), size); 37#else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 38 return ::operator new(size); 39#endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 40} 41 42asio_handler_deallocate_is_deprecated 43asio_handler_deallocate(void* pointer, std::size_t size, ...) 44{ 45#if defined(BOOST_ASIO_NO_DEPRECATED) 46 (void)pointer; 47 (void)size; 48 return asio_handler_deallocate_is_no_longer_used(); 49#elif !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 50 detail::thread_info_base::deallocate( 51 detail::thread_context::top_of_thread_call_stack(), pointer, size); 52#else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 53 (void)size; 54 ::operator delete(pointer); 55#endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING) 56} 57 58} // namespace asio 59} // namespace boost 60 61#include <boost/asio/detail/pop_options.hpp> 62 63#endif // BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP 64