LCOV - code coverage report
Current view: top level - json/detail/impl - stack.ipp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 23 23
Test Date: 2025-12-23 17:21:58 Functions: 100.0 % 3 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_DETAIL_IMPL_STACK_IPP
      11              : #define BOOST_JSON_DETAIL_IMPL_STACK_IPP
      12              : 
      13              : #include <boost/json/detail/stack.hpp>
      14              : 
      15              : namespace boost {
      16              : namespace json {
      17              : namespace detail {
      18              : 
      19      2185382 : stack::
      20              : ~stack()
      21              : {
      22      2185382 :     if(base_ != buf_)
      23       117701 :         sp_->deallocate(
      24       117701 :             base_, cap_);
      25      2185382 : }
      26              : 
      27        18855 : stack::
      28              : stack(
      29              :     storage_ptr sp,
      30              :     unsigned char* buf,
      31        18855 :     std::size_t buf_size) noexcept
      32        18855 :     : sp_(std::move(sp))
      33        18855 :     , cap_(buf_size)
      34        18855 :     , base_(buf)
      35        18855 :     , buf_(buf)
      36              : {
      37        18855 : }
      38              : 
      39              : void
      40       213127 : stack::
      41              : reserve(std::size_t n)
      42              : {
      43       213127 :     if(cap_ >= n)
      44        89423 :         return;
      45              :     auto const base = static_cast<
      46       123704 :         unsigned char*>(sp_->allocate(n));
      47       123702 :     if(base_)
      48              :     {
      49         6001 :         if(size_ > 0)
      50         5314 :             std::memcpy(base, base_, size_);
      51         6001 :         if(base_ != buf_)
      52         6001 :             sp_->deallocate(base_, cap_);
      53              :     }
      54       123702 :     base_ = base;
      55       123702 :     cap_ = n;
      56              : }
      57              : 
      58              : } // detail
      59              : } // namespace json
      60              : } // namespace boost
      61              : 
      62              : #endif
        

Generated by: LCOV version 2.1