26 #ifndef HYPERTABLE_ALLOCATOR_H
27 #define HYPERTABLE_ALLOCATOR_H
67 if (
sizeof(
void *) == 8)
68 return 8 - (((uint64_t)p) & 0x7);
70 return 4 - (((uint64_t)p) & 0x3);
93 pointer
address(reference x)
const {
return &x; }
100 const_pointer
address(const_reference x)
const {
return &x; }
120 template<
class U,
class... Args >
122 ::new((
void *)p) U(std::forward<Args>(args)...);
132 new(
static_cast<void*
>(p)) T();
158 template <
typename T,
class ArenaT>
175 template <
typename U>
177 : m_arenap(copy.m_arenap) {}
200 return (pointer)(::operator
new(sz *
sizeof(T)));
210 void deallocate(pointer p, size_type sz) {
if (!m_arenap) ::operator
delete(p); }
216 template <
typename U>
225 template <
typename U>
235 template <
typename U>
void construct(U *p, Args &&...args)
Creates a new object instance using placement new and the copy constructor.
Base::size_type size_type
Specialized Allocator class using a Memory Arena which manages the allocated memory; see PageArenaAll...
Base classes for all Allocator classes.
void deallocate(pointer p, size_type sz)
Deletes allocated objects unless an Arena Allocator was used (in this case the function is a nop) ...
size_t get_align_offset(void *p)
Convenience function returning a size aligned to 8 or 4 bytes, depending on the system's architecture...
pointer default_allocate(size_type sz)
Allocate an array of objects using the regular operator new.
size_type max_size() const
Returns the maximum number of objects that this Allocator can allocate; used to check for bad allocat...
const T & const_reference
ArenaAllocatorBase()
Default constructor; creates an empty object.
bool operator!=(const ArenaAllocatorBase< U, ArenaT > &x) const
operator != returns true if the arena pointers are not equal
void check_allocate_size(size_type sz) const
Sanity check the size of the requested buffer; if it's too large then most likely this is a bug in th...
void swap(ArenaAllocatorBase< U, ArenaT > &other)
Swaps the memory arena from another allocator with the arena of 'this' allocator. ...
ArenaAllocatorBase(ArenaT &arena)
Constructor; takes ownership of a pointer to a memory arena.
#define HT_THROW_(_code_)
void copy(TableDumper &, CellsBuilder &)
ArenaT * arena() const
Returns a pointer to the Arena.
ptrdiff_t difference_type
bool operator==(const ArenaAllocatorBase< U, ArenaT > &x) const
operator == returns true if the arena pointers are equal
ptrdiff_t difference_type
const_pointer address(const_reference x) const
Returns a const pointer to an object of type T.
ArenaAllocatorBase(const ArenaAllocatorBase< U, ArenaT > ©)
Copy Constructor; copies the memory arena.
void destroy(pointer p)
Calls the destructor of an object (unless it's a POD)
Error codes, Exception handling, error logging.
void destruct(char *)
helper functions which call the destructor of an object; destructor is not called on POD types (using...
const void * const_pointer
void construct(pointer p)
Creates a new object instance using placement new and the default constructor.
pointer address(reference x) const
Returns a pointer to an object of type T.
void set_arena(ArenaT *arena)
Sets the Arena pointer.