|
Electroneum
|
Go to the source code of this file.
Classes | |
| struct | regional |
Functions | |
| struct regional * | regional_create (void) |
| struct regional * | regional_create_custom (size_t size) |
| void | regional_free_all (struct regional *r) |
| void | regional_destroy (struct regional *r) |
| void * | regional_alloc (struct regional *r, size_t size) |
| void * | regional_alloc_init (struct regional *r, const void *init, size_t size) |
| void * | regional_alloc_zero (struct regional *r, size_t size) |
| char * | regional_strdup (struct regional *r, const char *string) |
| void | regional_log_stats (struct regional *r) |
| size_t | regional_get_mem (struct regional *r) |
Regional allocator. Allocates small portions of of larger chunks. Based on region-allocator from NSD, but rewritten to be light.
Different from (nsd) region-allocator.h o does not have recycle bin o does not collect stats; just enough to answer get_mem() in use. o does not keep cleanup list o does not have function pointers to setup o allocs the regional struct inside the first block. o can take a block to create regional from. o blocks and large allocations are kept on singly linked lists.
Definition in file regional.h.
| void* regional_alloc | ( | struct regional * | r, |
| size_t | size | ||
| ) |
Allocate size bytes of memory inside regional. The memory is deallocated when region_free_all is called for this region.
| r | the region. |
| size | number of bytes. |
| void* regional_alloc_init | ( | struct regional * | r, |
| const void * | init, | ||
| size_t | size | ||
| ) |
Allocate size bytes of memory inside regional and copy INIT into it. The memory is deallocated when region_free_all is called for this region.
| r | the region. |
| init | to copy. |
| size | number of bytes. |
| void* regional_alloc_zero | ( | struct regional * | r, |
| size_t | size | ||
| ) |
Allocate size bytes of memory inside regional that are initialized to 0. The memory is deallocated when region_free_all is called for this region.
| r | the region. |
| size | number of bytes. |
| struct regional* regional_create | ( | void | ) |
Create a new regional.
| struct regional* regional_create_custom | ( | size_t | size | ) |
Create a new region, with custom settings.
| size | length of first block. |
| void regional_destroy | ( | struct regional * | r | ) |
Destroy regional. All memory associated with regional is freed as if regional_free_all was called, as well as destroying the regional struct.
| r | to delete. |
| void regional_free_all | ( | struct regional * | r | ) |
Free all memory associated with regional. Only keeps the first block with the regional inside it.
| r | the region. |
| size_t regional_get_mem | ( | struct regional * | r | ) |
get total memory size in use by region
| void regional_log_stats | ( | struct regional * | r | ) |
Debug print regional statistics to log
| char* regional_strdup | ( | struct regional * | r, |
| const char * | string | ||
| ) |
Duplicate string and allocate the result in regional.
| r | the region. |
| string | null terminated string. |