|
Sturk 1.1.0
Publish-subscribe C implementation.
|
Arena allocator. More...
#include <stddef.h>

Go to the source code of this file.
Data Structures | |
| struct | StArenaGroup |
| Collection of arena instances. More... | |
Macros | |
| #define | ST_ARENA_ALLOC(arena, size) st_arena_alloc((arena), (size), __FILE__, __LINE__) |
| Allocate memory from an arena. | |
Typedefs | |
| typedef struct StArena | StArena |
| The arena. | |
Functions | |
| StArena * | st_arena_create (struct StArenaGroup *group, void *(*alloc_cb)(size_t), void(*free_cb)(void *)) |
| Create an arena. | |
| void | st_arena_destroy (StArena *arena) |
| Destroy an arena. | |
| void * | st_arena_alloc (StArena *arena, size_t size, const char *file, int line) |
| Allocate memory from an arena. | |
| void | st_arena_free (StArena *arena) |
| Free all the memory allocated from a single arena. | |
| void | st_arena_cleanup (struct StArenaGroup *group) |
| Free all the memory from an arena collection. | |
Arena allocator.
Solution inspired by the example from "C Interfaces and Implementations: Techniques for Creating Reusable Software" by David Hanson.
| void * st_arena_alloc | ( | StArena * | arena, |
| size_t | size, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Allocate memory from an arena.
| [in,out] | arena | The pointer to the arena. |
| [in,out] | size | The size in bytes of the requested memory. |
| [in] | file | The path to the calling source file. |
| [in] | line | The number of the calling line of code from the source file. |
| void st_arena_cleanup | ( | struct StArenaGroup * | group | ) |
Free all the memory from an arena collection.
| [in,out] | group | The arena collection. |
| StArena * st_arena_create | ( | struct StArenaGroup * | group, |
| void *(*)(size_t) | alloc, | ||
| void(*)(void *) | free | ||
| ) |
Create an arena.
| [in,out] | group | Collection of arena instances. |
| [in] | alloc | Memory allocation callback. |
| [in] | free | Memory freeing callback. |
| void st_arena_destroy | ( | StArena * | arena | ) |
Destroy an arena.
| [in,out] | arena | The pointer to the arena. |
| void st_arena_free | ( | StArena * | arena | ) |
Free all the memory allocated from a single arena.
| [in,out] | arena | The pointer to the arena. |