LCOV - code coverage report
Current view: top level - json/impl - static_resource.ipp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 81.8 % 22 18
Test Date: 2026-01-05 13:48:39 Functions: 60.0 % 5 3

            Line data    Source code
       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            7 : static_resource::
      21              : static_resource(
      22              :     unsigned char* buffer,
      23            7 :     std::size_t size) noexcept
      24            7 :     : p_(buffer)
      25            7 :     , n_(size)
      26            7 :     , size_(size)
      27              : {
      28            7 : }
      29              : 
      30              : void
      31            1 : static_resource::
      32              : release() noexcept
      33              : {
      34            1 :     p_ = reinterpret_cast<
      35            1 :         char*>(p_) - (size_ - n_);
      36            1 :     n_ = size_;
      37            1 : }
      38              : 
      39              : void*
      40           10 : static_resource::
      41              : do_allocate(
      42              :     std::size_t n,
      43              :     std::size_t align)
      44              : {
      45           10 :     auto p = std::align(align, n, p_, n_);
      46           10 :     if(! p)
      47            4 :         throw_exception( std::bad_alloc(), BOOST_CURRENT_LOCATION );
      48            8 :     p_ = reinterpret_cast<char*>(p) + n;
      49            8 :     n_ -= n;
      50            8 :     return p;
      51              : }
      52              : 
      53              : void
      54            0 : static_resource::
      55              : do_deallocate(
      56              :     void*,
      57              :     std::size_t,
      58              :     std::size_t)
      59              : {
      60              :     // do nothing
      61            0 : }
      62              : 
      63              : bool
      64            0 : static_resource::
      65              : do_is_equal(
      66              :     memory_resource const& mr) const noexcept
      67              : {
      68            0 :     return this == &mr;
      69              : }
      70              : 
      71              : } // namespace json
      72              : } // namespace boost
      73              : 
      74              : #endif
        

Generated by: LCOV version 2.1