50#define ALIGN4_VAL(x) (((x) + 3) & ~3)
64 if (current_blk->
free && current_blk->
size >= size)
69 if (current_blk->
size >= size + min_split_size)
76 .next = current_blk->
next,
80 current_blk->
size = size;
81 current_blk->
free =
false;
82 current_blk->
next = new_blk;
85 current_blk->
free =
false;
91 current_blk = current_blk->
next;
118 while (current_blk && current_blk != blk)
121 current_blk = current_blk->
next;
124 if (prev && prev->free)
127 prev->next = blk->
next;
151 if (new_size <= blk->size)
156 if (blk->
size >= new_size + min_split_thresh)
166 blk->
size = new_size;
179 memcpy(new_ptr, ptr, blk->
size);
void MEM_Free(MEM_Allocator *ma, void *ptr)
Free a previously allocated block.
MEM_Allocator * MEM_Init(void *pool, u32 pool_size)
Creates a new allocator from the given memory pool.
void * MEM_Alloc(MEM_Allocator *ma, u32 size)
Allocate a block of memory from the pool with at least 'size' bytes.
void * MEM_Realloc(MEM_Allocator *ma, void *ptr, u32 new_size)
Reallocate a previously allocated block to a new size.
_PRIVATE MEM_Allocator sAllocator