From fc0be9173cab4e905288e271eefac64b89bf88fa Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 11 Sep 2020 19:53:35 -0700 Subject: [PATCH] Remove unused files --- include/boost/json/detail/impl/raw_stack.ipp | 74 --------- include/boost/json/detail/raw_stack.hpp | 161 ------------------- include/boost/json/src.hpp | 1 - include/boost/json/value_stack.hpp | 1 - test/limits.cpp | 36 ----- 5 files changed, 273 deletions(-) delete mode 100644 include/boost/json/detail/impl/raw_stack.ipp delete mode 100644 include/boost/json/detail/raw_stack.hpp diff --git a/include/boost/json/detail/impl/raw_stack.ipp b/include/boost/json/detail/impl/raw_stack.ipp deleted file mode 100644 index 31a013c7..00000000 --- a/include/boost/json/detail/impl/raw_stack.ipp +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// Official repository: https://github.com/cppalliance/json -// - -#ifndef BOOST_JSON_DETAIL_IMPL_RAW_STACK_IPP -#define BOOST_JSON_DETAIL_IMPL_RAW_STACK_IPP - -#include -#include -#include - -BOOST_JSON_NS_BEGIN -namespace detail { - -void -raw_stack:: -reserve(std::size_t bytes) -{ - if(bytes <= capacity_) - return; - if(bytes > max_size()) - detail::throw_length_error( - "stack overflow", - BOOST_CURRENT_LOCATION); - if( bytes < min_capacity_) - bytes = min_capacity_; - - // 2x growth factor - { - if( capacity_ <= - max_size() - capacity_) - { - auto hint = - (capacity_ * 2) & ~1; - if( bytes < hint) - bytes = hint; - } - else - { - bytes = max_size(); - } - } - - auto base = reinterpret_cast< - char*>(sp_->allocate(bytes)); - if(base_) - { - std::memcpy(base, base_, size_); - sp_->deallocate(base_, capacity_); - } - base_ = base; - capacity_ = bytes; -} - -void -raw_stack:: -grow(std::size_t n) -{ - if(n > max_size() - capacity_) - detail::throw_length_error( - "stack overflow", - BOOST_CURRENT_LOCATION); - reserve(capacity_ + n); -} - -} // detail -BOOST_JSON_NS_END - -#endif diff --git a/include/boost/json/detail/raw_stack.hpp b/include/boost/json/detail/raw_stack.hpp deleted file mode 100644 index 6cb32dec..00000000 --- a/include/boost/json/detail/raw_stack.hpp +++ /dev/null @@ -1,161 +0,0 @@ -// -// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// Official repository: https://github.com/cppalliance/json -// - -#ifndef BOOST_JSON_DETAIL_RAW_STACK_HPP -#define BOOST_JSON_DETAIL_RAW_STACK_HPP - -#include -#include -#include -#include - -BOOST_JSON_NS_BEGIN -namespace detail { - -class raw_stack -{ - storage_ptr sp_; - std::size_t size_ = 0; - std::size_t capacity_ = 0; - char* base_ = nullptr; - -public: - explicit - raw_stack( - storage_ptr sp = {}) - : sp_(std::move(sp)) - { - } - - ~raw_stack() - { - if(base_) - sp_->deallocate( - base_, size_); - } - - bool - empty() const noexcept - { - return size_ == 0; - } - - std::size_t - top() const noexcept - { - return size_; - } - - BOOST_JSON_DECL - void - reserve(std::size_t bytes); - - void - clear() noexcept - { - size_ = 0; - } - - char* - push(std::size_t n) - { - prepare(n); - auto p = base_ + size_; - size_ += n; - return p; - } - - char* - behind(std::size_t n) noexcept - { - return base_ + size_ - n; - } - - char* - pop(std::size_t n) noexcept - { - BOOST_ASSERT( - n <= size_); - size_ -= n; - return base_ + size_; - } - - void - prepare(std::size_t n) - { - auto const avail = - capacity_ - size_; - if(n > avail) - grow(n - avail); - } - - void - add(std::size_t n) - { - prepare(n); - size_ += n; - } - - void - add_unchecked(std::size_t n) - { - BOOST_ASSERT(n <= - capacity_ - size_); - size_ += n; - } - - void - subtract(std::size_t n) - { - BOOST_ASSERT( - n <= size_); - size_ -= n; - } - - template - friend - char - align_to(raw_stack& rs) noexcept; - -private: - static - constexpr - std::size_t - min_capacity_ = 1024; - - static - constexpr - std::size_t - max_size() noexcept - { - return BOOST_JSON_MAX_STACK_SIZE; - } - - BOOST_JSON_DECL - void - grow(std::size_t n); -}; - -template -char -align_to(raw_stack& rs) noexcept -{ - auto const align = - static_cast( - alignof(T) * ((rs.size_ + - alignof(T) - 1) / alignof(T)) - - rs.size_); - rs.size_ += align; - return align; -} - -} // detail -BOOST_JSON_NS_END - -#endif diff --git a/include/boost/json/src.hpp b/include/boost/json/src.hpp index a89b4e91..ba821dba 100644 --- a/include/boost/json/src.hpp +++ b/include/boost/json/src.hpp @@ -49,7 +49,6 @@ in a translation unit of the program. #include #include #include -#include #include #include diff --git a/include/boost/json/value_stack.hpp b/include/boost/json/value_stack.hpp index 6bf966e0..02e4c559 100644 --- a/include/boost/json/value_stack.hpp +++ b/include/boost/json/value_stack.hpp @@ -14,7 +14,6 @@ #include #include #include -#include #include BOOST_JSON_NS_BEGIN diff --git a/test/limits.cpp b/test/limits.cpp index ad2cc92c..b96c1a67 100644 --- a/test/limits.cpp +++ b/test/limits.cpp @@ -221,41 +221,6 @@ public: } } - void - testStack() - { - // max raw_stack - // VFALCO The problem here is that we need the maximum stack - // larger than the maximum string to test string parts, - // but we need the opposite to test stack overflows. - // Thus stack overflow cannot be covered by tests. - #if 0 - { - std::string big; - value jv; - BOOST_TEST_THROWS( - jv = parse( - "[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0," - "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0," - "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0," - "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0," - "1,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ject(); testArray(); testString(); - testStack(); testParser(); #else