DungeonCrawl
|
Implements memory management functionality. More...
Go to the source code of this file.
Functions | |
memory_pool_t * | init_memory_pool (size_t size) |
Initialize a memory pool of the given size. | |
void * | memory_pool_alloc (memory_pool_t *pool, size_t size) |
Allocates memory on the given memory pool. | |
void | memory_pool_free (memory_pool_t *pool, void *ptr) |
Sets the given data pointer to not active in the given memory pool. | |
void | shutdown_memory_pool (memory_pool_t *pool) |
Shuts down the memory pool. |
Implements memory management functionality.
Definition in file memory_management.c.
memory_pool_t * init_memory_pool | ( | size_t | size | ) |
Initialize a memory pool of the given size.
size | the size of the memory pool to initialize, when the given size is smaller than 1MB, the size will be automatically set to 1MB |
Definition at line 15 of file memory_management.c.
void * memory_pool_alloc | ( | memory_pool_t * | pool, |
size_t | size ) |
Allocates memory on the given memory pool.
Allocate a memory pool.
If the remaining memory space is lager enough, creates a new unused block for the remaining memory.
pool | the pool to allocate memory from |
size | the size of the memory to allocate |
Definition at line 51 of file memory_management.c.
void memory_pool_free | ( | memory_pool_t * | pool, |
void * | ptr ) |
Sets the given data pointer to not active in the given memory pool.
Free a memory pool.
But first checks if the pointer is contained in the memory pool. If needed it will defragment the memory pool and merge free blocks.
pool | the pool to free memory from |
ptr | the pointer to the memory to free |
Definition at line 94 of file memory_management.c.
void shutdown_memory_pool | ( | memory_pool_t * | pool | ) |
Shuts down the memory pool.
pool | The memory pool to be shut down. |
Definition at line 120 of file memory_management.c.