20 #ifndef RIPPLE_BASICS_QALLOC_H_INCLUDED
21 #define RIPPLE_BASICS_QALLOC_H_INCLUDED
23 #include <ripple/basics/ByteUtilities.h>
24 #include <ripple/basics/contract.h>
25 #include <boost/intrusive/list.hpp>
39 template <
class =
void>
89 template <
class T,
bool ShareOnCopy = true>
93 template <
class,
bool>
109 explicit rebind() =
default;
175 : bytes_(bytes - sizeof(*this))
177 , free_(reinterpret_cast<
std::uint8_t*>(this + 1))
188 return (a - (i % a)) % a;
191 auto const n0 = pad(
free_ +
sizeof(
block*), align);
192 auto const n1 = n0 +
sizeof(
block*) + bytes;
257 ((
sizeof(block) +
sizeof(block*) + bytes) + (adj_align - 1)) &
259 auto const n = std::max<std::size_t>(
block_size, min_alloc);
262 Throw<std::bad_alloc>();
272 auto const b =
reinterpret_cast<block**
>(p)[-1];
286 template <
class T,
bool ShareOnCopy>
292 template <
class T,
bool ShareOnCopy>
299 template <
class T,
bool ShareOnCopy>
305 Throw<std::bad_alloc>();
306 auto const bytes = n *
sizeof(U);
310 template <
class T,
bool ShareOnCopy>
315 impl_->deallocate(p);
318 template <
class T,
bool ShareOnCopy>
325 template <
class T,
bool ShareOnCopy>
332 template <
class T,
bool ShareOnCopy>
337 return impl_.
get() == u.
impl_.get();
340 template <
class T,
bool ShareOnCopy>
345 return !(*
this == u);
348 template <
class T,
bool ShareOnCopy>
356 template <
class T,
bool ShareOnCopy>
363 template <
class T,
bool ShareOnCopy>
qalloc_type select_on_copy(std::true_type) const
T * allocate(std::size_t n)
qalloc_type & operator=(qalloc_type const &)=default
void * allocate(std::size_t bytes, std::size_t align)
static constexpr auto block_size
typename std::add_lvalue_reference< int const >::type const_reference
constexpr auto kilobytes(T value) noexcept
void * allocate(std::size_t bytes, std::size_t align)
std::shared_ptr< detail::qalloc_impl<> > impl_
typename std::add_lvalue_reference< int >::type reference
qalloc_impl & operator=(qalloc_impl const &)=delete
int const * const_pointer
void dealloc(U *p, std::size_t n)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
block(block const &)=delete
qalloc_type select_on_container_copy_construction() const
block & operator=(block const &)=delete
void deallocate(T *p, std::size_t n)