39 static constexpr
size_t alignment_boundary = 1;
105 virtual void *
malloc(
size_t bytes,
size_t alignment = alignment_boundary) = 0;
148 static size_t realign(
const void *address,
size_t boundary)
150 return realign((uintptr_t)address, boundary);
168 static size_t realign(uintptr_t current_pointer,
size_t boundary)
173 size_t padding = (current_pointer % boundary == 0) ? 0 : boundary - current_pointer % boundary;
189 virtual void rewind(
void) = 0;
virtual ~allocator()
Destructor.
Definition: allocator.h:66
std::atomic< size_t > allocated
The number of bytes this object has allocated.
Definition: allocator.h:43
virtual bool operator!=(const allocator &with)=0
Compare for inequlity two objects of this class type.
allocator()
Constructor.
Definition: allocator.h:53
Virtual base class for C style allocators.
Definition: allocator.h:33
virtual void rewind(void)=0
Throw away (without calling delete) all objects allocated in the memory space of this allocator Delet...
virtual void * malloc(size_t bytes, size_t alignment=alignment_boundary)=0
Allocate a small chunk of memory from the internal pool and return a pointer to the caller...
std::atomic< size_t > used
The number of bytes this object has passed back to the caller.
Definition: allocator.h:42
virtual bool operator==(const allocator &with)=0
Compare for equality two objects of this class type.
size_t size(void) const
Return the number of bytes of memory this object has handed back to callers.
Definition: allocator.h:128
static size_t realign(const void *address, size_t boundary)
Compute the number of extra bytes of memory necessary for an allocation to start on an aligned bounda...
Definition: allocator.h:148
static size_t realign(uintptr_t current_pointer, size_t boundary)
Compute the number of extra bytes of memory necessary for an allocation to start on an aligned bounda...
Definition: allocator.h:168
Definition: compress_integer_elias_delta_simd.c:23
static constexpr size_t alignment_boundary
Elsewhere don't bother with alignment (align on byte boundaries)
Definition: allocator.h:39
size_t capacity(void) const
Return the amount of memory that this object has allocated to it.
Definition: allocator.h:115