Pool allocator.
More...
#include "align.h"
#include <stdalign.h>
#include <stddef.h>
#include <string.h>
Go to the source code of this file.
|
static void | pool_deallocate_all (struct pool *self) |
| Deallocate pool and restore all free nodes.
|
|
static void | pool_init (struct pool *self, const size_t len, unsigned char *backing_buf, const size_t data_size, const size_t data_alignment) |
| Initialize pool for given data size and alignment.
|
|
static void * | pool_allocate (struct pool *self) |
| Get a pointer to a free block of previously given data size.
|
|
static void | pool_deallocate (struct pool *self, void *ptr) |
| Free a memory chunk for further reuse.
|
|
Pool allocator.
For a comprehensive source, read:
◆ pool_allocate()
static void * pool_allocate |
( |
struct pool * | self | ) |
|
|
inlinestatic |
Get a pointer to a free block of previously given data size.
- Parameters
-
- Returns
- A pointer to a zeroed-out memory chunk of data size.
◆ pool_deallocate()
static void pool_deallocate |
( |
struct pool * | self, |
|
|
void * | ptr ) |
|
inlinestatic |
Free a memory chunk for further reuse.
- Parameters
-
[in] | self | Pool pointer |
[in] | ptr | Pointer to memory chunk |
◆ pool_deallocate_all()
static void pool_deallocate_all |
( |
struct pool * | self | ) |
|
|
inlinestatic |
Deallocate pool and restore all free nodes.
- Parameters
-
[in] | self | The pool pointer. |
◆ pool_init()
static void pool_init |
( |
struct pool * | self, |
|
|
const size_t | len, |
|
|
unsigned char * | backing_buf, |
|
|
const size_t | data_size, |
|
|
const size_t | data_alignment ) |
|
inlinestatic |
Initialize pool for given data size and alignment.
- Parameters
-
[in] | self | pool pointer |
[in] | len | backing buffer length |
[in] | backing_buf | backing buffer |
[in] | data_size | data size |
[in] | data_alignment | data alignment |