2
0
mirror of https://github.com/boostorg/json.git synced 2026-01-19 04:12:14 +00:00

Remove unused files

This commit is contained in:
Vinnie Falco
2020-09-11 19:53:35 -07:00
parent 7b7a977fd4
commit fc0be9173c
5 changed files with 0 additions and 273 deletions

View File

@@ -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 <boost/json/detail/raw_stack.hpp>
#include <boost/json/detail/except.hpp>
#include <cstring>
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

View File

@@ -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 <boost/json/detail/config.hpp>
#include <boost/json/storage_ptr.hpp>
#include <cstdlib>
#include <utility>
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<class T>
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<class T>
char
align_to(raw_stack& rs) noexcept
{
auto const align =
static_cast<char>(
alignof(T) * ((rs.size_ +
alignof(T) - 1) / alignof(T)) -
rs.size_);
rs.size_ += align;
return align;
}
} // detail
BOOST_JSON_NS_END
#endif

View File

@@ -49,7 +49,6 @@ in a translation unit of the program.
#include <boost/json/detail/impl/except.ipp>
#include <boost/json/detail/impl/format.ipp>
#include <boost/json/detail/impl/object_impl.ipp>
#include <boost/json/detail/impl/raw_stack.ipp>
#include <boost/json/detail/impl/stack.ipp>
#include <boost/json/detail/impl/string_impl.ipp>

View File

@@ -14,7 +14,6 @@
#include <boost/json/error.hpp>
#include <boost/json/storage_ptr.hpp>
#include <boost/json/value.hpp>
#include <boost/json/detail/raw_stack.hpp>
#include <stddef.h>
BOOST_JSON_NS_BEGIN

View File

@@ -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,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,2,3,4,5,6,7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