103 memset(
new, 0, mem->
size);
119 assert((mem != NULL) && (ptr != NULL));
121 memcpy(ptr, &mem->
free_data,
sizeof(
void *));
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
void free(void *ptr)
This is a no-op.
static void * memarray_alloc(memarray_t *mem)
Allocate memory chunk in memarray pool.
void memarray_init(memarray_t *mem, void *data, size_t size, size_t num)
Initialize memarray pool with free list.
size_t memarray_available(memarray_t *mem)
Returns the number of blocks available.
static void * memarray_calloc(memarray_t *mem)
Allocate and clear memory chunk in memarray pool.
int memarray_reduce(memarray_t *mem, void *data, size_t num)
Reduce the memarray space, subtracting the memory pool.
static void memarray_free(memarray_t *mem, void *ptr)
Free memory chunk in memarray pool.
struct memarray_element memarray_element_t
Memory pool element.
void memarray_extend(memarray_t *mem, void *data, size_t num)
Extend the memarray with a new memory region.
struct memarray_element * next
Pointer to the next element.
void * free_data
memory pool data / head of the free list
size_t size
size of single list element