Coverage Report

Created: 2026-06-15 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boost/boost/json/impl/static_resource.ipp
Line
Count
Source
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_IMPL_STATIC_RESOURCE_IPP
11
#define BOOST_JSON_IMPL_STATIC_RESOURCE_IPP
12
13
#include <boost/json/static_resource.hpp>
14
#include <boost/throw_exception.hpp>
15
#include <memory>
16
17
namespace boost {
18
namespace json {
19
20
static_resource::
21
static_resource(
22
    unsigned char* buffer,
23
    std::size_t size) noexcept
24
2.90k
    : p_(buffer)
25
2.90k
    , n_(size)
26
2.90k
    , size_(size)
27
2.90k
{
28
2.90k
}
29
30
void
31
static_resource::
32
release() noexcept
33
0
{
34
0
    p_ = reinterpret_cast<
35
0
        char*>(p_) - (size_ - n_);
36
0
    n_ = size_;
37
0
}
38
39
void*
40
static_resource::
41
do_allocate(
42
    std::size_t n,
43
    std::size_t align)
44
6.60k
{
45
6.60k
    auto p = std::align(align, n, p_, n_);
46
6.60k
    if(! p)
47
17
        throw_exception( std::bad_alloc(), BOOST_CURRENT_LOCATION );
48
6.59k
    p_ = reinterpret_cast<char*>(p) + n;
49
6.59k
    n_ -= n;
50
6.59k
    return p;
51
6.60k
}
52
53
void
54
static_resource::
55
do_deallocate(
56
    void*,
57
    std::size_t,
58
    std::size_t)
59
244
{
60
    // do nothing
61
244
}
62
63
bool
64
static_resource::
65
do_is_equal(
66
    memory_resource const& mr) const noexcept
67
0
{
68
0
    return this == &mr;
69
0
}
70
71
} // namespace json
72
} // namespace boost
73
74
#endif