27 #include "precompiled.h"
36 namespace Allocators {
38 template<
class Storage>
68 ENSURE(p2 == (
double*)(uintptr_t(p1)+
sizeof(
double)));
78 ForEachStorage<BasicPoolTest>();
91 p->
el_size = Align<allocationAlignment>(el_size);
111 if(!(p->
da.
base <= el && el < p->da.base+p->
da.
pos))
125 const size_t el_size = p->
el_size? p->
el_size : Align<allocationAlignment>(size);
138 p->
da.
pos += el_size;
void pool_free(Pool *p, void *el)
Make a fixed-size element available for reuse in the given Pool.
void * pool_alloc(Pool *p, size_t size)
Dole out memory from the pool.
#define ASSERT(expr)
same as ENSURE in debug mode, does nothing in release mode.
void * freelist
pointer to freelist (opaque); see freelist_*.
size_t pool_committed(Pool *p)
Return the number of bytes committed in the pool's backing array.
Status pool_create(Pool *p, size_t max_size, size_t el_size)
Ready Pool for use.
static void * mem_freelist_Detach(void *&freelist)
#define TIMER_ACCRUE(client)
Measure the time taken to execute code up until end of the current scope; bill it to the given TimerC...
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
size_t RemainingObjects()
allocator design parameters:
Status da_set_size(DynArray *da, size_t new_size)
expand or shrink the array: changes the amount of currently committed (i.e.
const size_t POOL_VARIABLE_ALLOCS
pass as pool_create's <el_size> param to indicate variable-sized allocs are required (see below)...
bool Contains(uintptr_t address) const
i64 Status
Error handling system.
allocator design parameters:
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
#define TIMER_ADD_CLIENT(id)
"allocate" a new TimerClient that will keep track of the total time billed to it, along with a descri...
size_t el_size
size of elements.
void pool_free_all(Pool *p)
"free" all user allocations that ensued from the given Pool.
Status da_free(DynArray *da)
free all memory (address space + physical) that constitutes the given array.
Status pool_destroy(Pool *p)
free all memory (address space + physical) that constitutes the given Pool.
Status da_reserve(DynArray *da, size_t size)
Make sure at least <size> bytes starting at da->pos are committed and ready for use.
Status da_alloc(DynArray *da, size_t max_size)
ready the DynArray object for use.
void * mem_freelist_Sentinel()
#define RETURN_STATUS_IF_ERR(expression)
bool pool_contains(const Pool *p, void *el)
indicate whether a pointer was allocated from the given pool.
static void mem_freelist_AddToFront(void *&freelist, void *el)