]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/json/detail/impl/stack.ipp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / json / detail / impl / stack.ipp
CommitLineData
20effc67
TL
1//
2// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// Official repository: https://github.com/boostorg/json
8//
9
10#ifndef BOOST_JSON_DETAIL_IMPL_STACK_IPP
11#define BOOST_JSON_DETAIL_IMPL_STACK_IPP
12
13#include <boost/json/detail/stack.hpp>
14
15BOOST_JSON_NS_BEGIN
16namespace detail {
17
18stack::
19~stack()
20{
21 if(buf_)
22 sp_->deallocate(
23 buf_, cap_);
24}
25
26void
27stack::
28reserve(std::size_t n)
29{
30 if(cap_ >= n)
31 return;
32 auto const buf = static_cast<
33 char*>(sp_->allocate(n));
34 if(buf_)
35 {
36 if(size_ > 0)
37 std::memcpy(buf, buf_, size_);
38 sp_->deallocate(buf_, cap_);
39 }
40 buf_ = buf;
41 cap_ = n;
42}
43
44} // detail
45BOOST_JSON_NS_END
46
47#endif