22 return get_global_ptr()->ns_alloc(size);
31 return get_global_ptr()->_total_alloc;
40 return get_global_ptr()->_total_used;
51 global_ptr->_lock.lock();
52 size_t total_unused = global_ptr->_total_alloc - global_ptr->_total_used;
53 global_ptr->_lock.unlock();
62 if (_global_ptr ==
nullptr) {
71 INLINE NeverFreeMemory::Page::
72 Page(
void *start,
size_t size) :
73 _next((unsigned char *)start),
81 INLINE
bool NeverFreeMemory::Page::
82 operator < (
const NeverFreeMemory::Page &other)
const {
83 return _remaining < other._remaining;
89 INLINE
void *NeverFreeMemory::Page::
91 assert(size <= _remaining);
This class is used to allocate bytes of memory from a pool that is never intended to be freed.
static size_t get_total_unused()
Returns the difference between get_total_alloc() and get_total_used().
static size_t get_total_alloc()
Returns the total number of bytes consumed by all the pages allocated internally by this object.
static void * alloc(size_t size)
Returns a pointer to a newly-allocated block of memory of the indicated size.
static size_t get_total_used()
Returns the total number of bytes requested by the application in calls to NeverFreeMemory::alloc().