First-class heaps that can be destroyed in one go. More...
Typedefs | |
typedef struct mi_heap_s | mi_heap_t |
Type of first-class heaps. More... | |
Functions | |
mi_heap_t * | mi_heap_new () |
Create a new heap that can be used for allocation. More... | |
void | mi_heap_delete (mi_heap_t *heap) |
Delete a previously allocated heap. More... | |
void | mi_heap_destroy (mi_heap_t *heap) |
Destroy a heap, freeing all its still allocated blocks. More... | |
mi_heap_t * | mi_heap_set_default (mi_heap_t *heap) |
Set the default heap to use for mi_malloc() et al. More... | |
mi_heap_t * | mi_heap_get_default () |
Get the default heap that is used for mi_malloc() et al. More... | |
mi_heap_t * | mi_heap_get_backing () |
Get the backing heap. More... | |
void * | mi_heap_malloc (mi_heap_t *heap, size_t size) |
Allocate in a specific heap. More... | |
void * | mi_heap_zalloc (mi_heap_t *heap, size_t size) |
Allocate zero-initialized in a specific heap. More... | |
void * | mi_heap_calloc (mi_heap_t *heap, size_t count, size_t size) |
Allocate count zero-initialized elements in a specific heap. More... | |
void * | mi_heap_mallocn (mi_heap_t *heap, size_t count, size_t size) |
Allocate count elements in a specific heap. More... | |
char * | mi_heap_strdup (mi_heap_t *heap, const char *s) |
Duplicate a string in a specific heap. More... | |
char * | mi_heap_strndup (mi_heap_t *heap, const char *s, size_t n) |
Duplicate a string of at most length n in a specific heap. More... | |
char * | mi_heap_realpath (mi_heap_t *heap, const char *fname, char *resolved_name) |
Resolve a file path name using a specific heap to allocate the result. More... | |
void * | mi_heap_realloc (mi_heap_t *heap, void *p, size_t newsize) |
void * | mi_heap_reallocn (mi_heap_t *heap, void *p, size_t count, size_t size) |
void * | mi_heap_reallocf (mi_heap_t *heap, void *p, size_t newsize) |
void * | mi_heap_malloc_aligned (mi_heap_t *heap, size_t size, size_t alignment) |
void * | mi_heap_malloc_aligned_at (mi_heap_t *heap, size_t size, size_t alignment, size_t offset) |
void * | mi_heap_zalloc_aligned (mi_heap_t *heap, size_t size, size_t alignment) |
void * | mi_heap_zalloc_aligned_at (mi_heap_t *heap, size_t size, size_t alignment, size_t offset) |
void * | mi_heap_calloc_aligned (mi_heap_t *heap, size_t count, size_t size, size_t alignment) |
void * | mi_heap_calloc_aligned_at (mi_heap_t *heap, size_t count, size_t size, size_t alignment, size_t offset) |
void * | mi_heap_realloc_aligned (mi_heap_t *heap, void *p, size_t newsize, size_t alignment) |
void * | mi_heap_realloc_aligned_at (mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset) |
First-class heaps that can be destroyed in one go.
typedef struct mi_heap_s mi_heap_t |
Type of first-class heaps.
A heap can only be used for (re)allocation in the thread that created this heap! Any allocated blocks can be freed by any other thread though.
void* mi_heap_calloc | ( | mi_heap_t * | heap, |
size_t | count, | ||
size_t | size | ||
) |
Allocate count zero-initialized elements in a specific heap.
void* mi_heap_calloc_aligned | ( | mi_heap_t * | heap, |
size_t | count, | ||
size_t | size, | ||
size_t | alignment | ||
) |
void* mi_heap_calloc_aligned_at | ( | mi_heap_t * | heap, |
size_t | count, | ||
size_t | size, | ||
size_t | alignment, | ||
size_t | offset | ||
) |
void mi_heap_delete | ( | mi_heap_t * | heap | ) |
Delete a previously allocated heap.
This will release resources and migrate any still allocated blocks in this heap (efficienty) to the default heap.
If heap is the default heap, the default heap is set to the backing heap.
void mi_heap_destroy | ( | mi_heap_t * | heap | ) |
Destroy a heap, freeing all its still allocated blocks.
Use with care as this will free all blocks still allocated in the heap. However, this can be a very efficient way to free all heap memory in one go.
If heap is the default heap, the default heap is set to the backing heap.
mi_heap_t* mi_heap_get_backing | ( | ) |
Get the backing heap.
The backing heap is the initial default heap for a thread and always available for allocations. It cannot be destroyed or deleted except by exiting the thread.
mi_heap_t* mi_heap_get_default | ( | ) |
Get the default heap that is used for mi_malloc() et al.
void* mi_heap_malloc | ( | mi_heap_t * | heap, |
size_t | size | ||
) |
Allocate in a specific heap.
void* mi_heap_malloc_aligned | ( | mi_heap_t * | heap, |
size_t | size, | ||
size_t | alignment | ||
) |
void* mi_heap_malloc_aligned_at | ( | mi_heap_t * | heap, |
size_t | size, | ||
size_t | alignment, | ||
size_t | offset | ||
) |
void* mi_heap_mallocn | ( | mi_heap_t * | heap, |
size_t | count, | ||
size_t | size | ||
) |
Allocate count elements in a specific heap.
mi_heap_t* mi_heap_new | ( | ) |
Create a new heap that can be used for allocation.
void* mi_heap_realloc | ( | mi_heap_t * | heap, |
void * | p, | ||
size_t | newsize | ||
) |
void* mi_heap_realloc_aligned | ( | mi_heap_t * | heap, |
void * | p, | ||
size_t | newsize, | ||
size_t | alignment | ||
) |
void* mi_heap_realloc_aligned_at | ( | mi_heap_t * | heap, |
void * | p, | ||
size_t | newsize, | ||
size_t | alignment, | ||
size_t | offset | ||
) |
void* mi_heap_reallocf | ( | mi_heap_t * | heap, |
void * | p, | ||
size_t | newsize | ||
) |
void* mi_heap_reallocn | ( | mi_heap_t * | heap, |
void * | p, | ||
size_t | count, | ||
size_t | size | ||
) |
char* mi_heap_realpath | ( | mi_heap_t * | heap, |
const char * | fname, | ||
char * | resolved_name | ||
) |
Resolve a file path name using a specific heap to allocate the result.
Set the default heap to use for mi_malloc() et al.
heap | The new default heap. |
char* mi_heap_strdup | ( | mi_heap_t * | heap, |
const char * | s | ||
) |
Duplicate a string in a specific heap.
char* mi_heap_strndup | ( | mi_heap_t * | heap, |
const char * | s, | ||
size_t | n | ||
) |
Duplicate a string of at most length n in a specific heap.
void* mi_heap_zalloc | ( | mi_heap_t * | heap, |
size_t | size | ||
) |
Allocate zero-initialized in a specific heap.
void* mi_heap_zalloc_aligned | ( | mi_heap_t * | heap, |
size_t | size, | ||
size_t | alignment | ||
) |
void* mi_heap_zalloc_aligned_at | ( | mi_heap_t * | heap, |
size_t | size, | ||
size_t | alignment, | ||
size_t | offset | ||
) |