xmempool 1.1.2
A memory pool implemented by C.
|
A memory pool implemented by C. More...
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | XMEMPOOL_VERSION_MAJOR 1 |
Major version number of xmempool. | |
#define | XMEMPOOL_VERSION_MINOR 1 |
Minor version number of xmempool. | |
#define | XMEMPOOL_VERSION_PATCH 2 |
Patch version number of xmempool. | |
#define | XMEMPOOL_VERSION_STRING "1.1.2" |
Version string of xmempool. | |
Typedefs | |
typedef char * | xmem_pool_handle |
Handle type for memory pools. | |
Functions | |
xmem_pool_handle | xmem_create_pool (uint32_t block_size) |
Create a new memory pool. | |
void | xmem_destroy_pool (xmem_pool_handle pool) |
Destroy a memory pool and free all associated resources. | |
char * | xmem_alloc (xmem_pool_handle handle) |
Allocate a block from the memory pool. | |
int | xmem_free (xmem_pool_handle handle, char *pointer) |
Free a block back to the memory pool. | |
void | xmem_print_info (xmem_pool_handle pool) |
Print information about the memory pool. | |
void | xmem_clean_up () |
Clean up global resources used by xmempool. | |
A memory pool implemented by C.
Definition in file xmempool.h.
#define XMEMPOOL_VERSION_MAJOR 1 |
Major version number of xmempool.
Definition at line 26 of file xmempool.h.
#define XMEMPOOL_VERSION_MINOR 1 |
Minor version number of xmempool.
Definition at line 31 of file xmempool.h.
#define XMEMPOOL_VERSION_PATCH 2 |
Patch version number of xmempool.
Definition at line 36 of file xmempool.h.
#define XMEMPOOL_VERSION_STRING "1.1.2" |
Version string of xmempool.
Definition at line 41 of file xmempool.h.
typedef char* xmem_pool_handle |
Handle type for memory pools.
This is a pointer to the first pool in the chain of memory pools. It's used as an opaque handle to interact with the memory pool system.
Definition at line 49 of file xmempool.h.
|
extern |
Allocate a block from the memory pool.
This function returns a pointer to a free block from the pool. If the current pool is full, it automatically creates and chains a new pool. The allocated block is always zero-initialized.
handle | Handle to the pool to allocate from |
|
extern |
Clean up global resources used by xmempool.
This function frees all global resources used by the xmempool system, particularly the memory used for managing block nodes. It should be called when the xmempool system is no longer needed.
|
extern |
Create a new memory pool.
This function creates the initial memory pool with the specified block size. It allocates a large chunk of memory and divides it into fixed-size blocks. Additional pools will be created automatically as needed.
block_size | Size of each block in the pool |
|
extern |
Destroy a memory pool and free all associated resources.
This function frees all memory associated with the pool, including all chained pools and their blocks. It also recovers all block nodes used for managing free blocks.
pool | Handle to the pool to be destroyed |
|
extern |
Free a block back to the memory pool.
This function returns a block to the free list of the first pool in the chain. It does not actually free memory, but makes the block available for future allocations.
handle | Handle to the pool |
pointer | Pointer to the block to be freed |
|
extern |
Print information about the memory pool.
This function prints detailed information about each pool in the chain, including its size, block count, memory range, and number of free blocks.
pool | Handle to the pool |