neomimalloc.c.mimalloc

This module provides low-level bindings with the mimalloc C interface

Members

Aliases

mi_block_visit_fun
alias mi_block_visit_fun = bool function(const(mi_heap_t)* heap, const(mi_heap_area_t)* area, void* block, size_t block_size, const(void)* arg)

Visitor function passed to mi_heap_visit_blocks()

mi_deferred_free_fun
alias mi_deferred_free_fun = void function(bool force, ulong heartbeat)

Type of deferred free functions.

Enums

mi_option_t
enum mi_option_t

Runtime options.

Functions

mi__posix_memalign
int mi__posix_memalign(void** p, size_t alignment, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_aligned_alloc
void* mi_aligned_alloc(size_t alignment, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_calloc
void* mi_calloc(size_t count, size_t size)

Allocate zero-initialized count elements of size bytes.

mi_calloc_aligned
void* mi_calloc_aligned(size_t count, size_t size, size_t alignment)

Allocate zero-initialized count elements of size bytes aligned by alignment.

mi_calloc_aligned_at
void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset)

Allocate zero-initialized count elements of size bytes aligned by alignment at a specified offset.

mi_cfree
size_t mi_cfree(void* p)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_check_owned
bool mi_check_owned(const(void)* p)

Check safely if any pointer is part of the default heap of this thread.

mi_collect
void mi_collect(bool force)

Eagerly free memory.

mi_expand
void* mi_expand(void* p, size_t newsize)

Try to re-allocate memory to newsize bytes in place.

mi_free
void mi_free(void* p)

Free previously allocated memory.

mi_free_aligned
void mi_free_aligned(void* p, size_t alignment)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_free_size
void mi_free_size(void* p, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_free_size_aligned
void mi_free_size_aligned(void* p, size_t size, size_t alignment)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_good_size
size_t mi_good_size(size_t size)

Return the used allocation size.

mi_heap_calloc
void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size)

Allocate count zero-initialized elements in a specific heap.

mi_heap_calloc_aligned
void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment)

Allocate zero-initialized count elements of size bytes aligned by alignment in a specific heap.

mi_heap_calloc_aligned_at
void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset)

Allocate zero-initialized count elements of size bytes aligned by alignment at a specified offset in a specific heap.

mi_heap_check_owned
bool mi_heap_check_owned(mi_heap_t* heap, const(void)* p)

Check safely if any pointer is part of a heap.

mi_heap_collect
void mi_heap_collect(mi_heap_t* heap, bool force)

Eagerly free memory in specific heap.

mi_heap_contains_block
bool mi_heap_contains_block(mi_heap_t* heap, const(void)* p)

Does a heap contain a pointer to a previously allocated block?

mi_heap_delete
void mi_heap_delete(mi_heap_t* heap)

Delete a previously allocated heap.

mi_heap_destroy
void mi_heap_destroy(mi_heap_t* heap)

Destroy a heap, freeing all its still allocated blocks.

mi_heap_get_backing
mi_heap_t* mi_heap_get_backing()

Get the backing heap.

mi_heap_get_default
mi_heap_t* mi_heap_get_default()

Get the default heap that is used for mi_malloc() et al.

mi_heap_malloc
void* mi_heap_malloc(mi_heap_t* heap, size_t size)

Allocate in a specific heap.

mi_heap_malloc_aligned
void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment)

Allocate size bytes aligned by alignment in a specific heap.

mi_heap_malloc_aligned_at
void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset)

Allocate size bytes aligned by alignment at a specified offset in a specific heap.

mi_heap_malloc_small
void* mi_heap_malloc_small(mi_heap_t* heap, size_t size)

Allocate a small object in a specific heap.

mi_heap_mallocn
void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size)

Allocate count elements in a specific heap.

mi_heap_new
mi_heap_t* mi_heap_new()

Create a new heap that can be used for allocation.

mi_heap_realloc
void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize)

Re-allocate memory to newsize bytes in a specific heap.

mi_heap_realloc_aligned
void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment)

Re-allocate memory to newsize bytes aligned by alignment in a specific heap.

mi_heap_realloc_aligned_at
void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset)

Re-allocate memory to newsize bytes aligned by alignment at a specified offset in a specific heap.

mi_heap_reallocf
void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize)

Re-allocate memory to newsize bytes in a specific heap.

mi_heap_reallocn
void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size)

Re-allocate memory to count elements of size bytes in a specific heap.

mi_heap_realpath
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.

mi_heap_set_default
mi_heap_t* mi_heap_set_default(mi_heap_t* heap)

Set the default heap to use for mi_malloc() et al.

mi_heap_strdup
char* mi_heap_strdup(mi_heap_t* heap, const(char)* s)

Duplicate a string in a specific heap.

mi_heap_strndup
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.

mi_heap_visit_blocks
bool mi_heap_visit_blocks(const(mi_heap_t)* heap, bool visit_all_blocks, mi_block_visit_fun visitor, const(void)* arg)

Visit all areas and blocks in a heap.

mi_heap_zalloc
void* mi_heap_zalloc(mi_heap_t* heap, size_t size)

Allocate zero-initialized in a specific heap.

mi_heap_zalloc_aligned
void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment)

Allocate zero-initialized size bytes aligned by alignment in a specific heap.

mi_heap_zalloc_aligned_at
void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset)

Allocate zero-initialized size bytes aligned by alignment at a specified offset in a specific heap.

mi_is_in_heap_region
bool mi_is_in_heap_region(const(void)* p)

Inspect the heap at runtime.

mi_malloc
void* mi_malloc(size_t size)

Allocate size bytes.

mi_malloc_aligned
void* mi_malloc_aligned(size_t size, size_t alignment)

Allocate size bytes aligned by alignment.

mi_malloc_aligned_at
void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset)

Allocate size bytes aligned by alignment at a specified offset.

mi_malloc_size
size_t mi_malloc_size(const(void)* p)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_malloc_small
void* mi_malloc_small(size_t size)

Allocate a small object.

mi_malloc_usable_size
size_t mi_malloc_usable_size(const(void)* p)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_mallocn
void* mi_mallocn(size_t count, size_t size)

Allocate count elements of size bytes.

mi_memalign
void* mi_memalign(size_t alignment, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_new
void* mi_new(size_t n)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_new_aligned
void* mi_new_aligned(size_t n, size_t alignment)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_new_aligned_nothrow
void* mi_new_aligned_nothrow(size_t n, size_t alignment)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_new_nothrow
void* mi_new_nothrow(size_t n)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_option_enable
void mi_option_enable(mi_option_t option, bool enable)

Set runtime behavior.

mi_option_enable_default
void mi_option_enable_default(mi_option_t option, bool enable)

Set runtime behavior.

mi_option_get
c_long mi_option_get(mi_option_t option)

Set runtime behavior.

mi_option_is_enabled
bool mi_option_is_enabled(mi_option_t option)

Set runtime behavior.

mi_option_set
void mi_option_set(mi_option_t option, c_long value)

Set runtime behavior.

mi_option_set_default
void mi_option_set_default(mi_option_t option, c_long value)

Set runtime behavior.

mi_posix_memalign
int mi_posix_memalign(void** p, size_t alignment, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_process_init
void mi_process_init()

Initialize mimalloc on a process

mi_pvalloc
void* mi_pvalloc(size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_realloc
void* mi_realloc(void* p, size_t newsize)

Re-allocate memory to newsize bytes.

mi_realloc_aligned
void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment)

Re-allocate memory to newsize bytes aligned by alignment.

mi_realloc_aligned_at
void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset)

Re-allocate memory to newsize bytes aligned by alignment at a specified offset.

mi_reallocarray
void* mi_reallocarray(void* p, size_t count, size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_reallocf
void* mi_reallocf(void* p, size_t newsize)

Re-allocate memory to newsize bytes.

mi_reallocn
void* mi_reallocn(void* p, size_t count, size_t size)

Re-allocate memory to count elements of size bytes.

mi_realpath
char* mi_realpath(const(char)* fname, char* resolved_name)

Resolve a file path name.

mi_recalloc
void* mi_recalloc(void* p, size_t count, size_t size)

Re-allocate memory to newsize bytes.

mi_register_deferred_free
void mi_register_deferred_free(const(mi_deferred_free_fun) deferred_free)

Register a deferred free function.

mi_stats_print
void mi_stats_print(FILE* out_)

Print statistics.

mi_stats_reset
void mi_stats_reset()

Reset statistics.

mi_strdup
char* mi_strdup(const(char)* s)

Allocate and duplicate a string.

mi_strndup
char* mi_strndup(const(char)* s, size_t n)

Allocate and duplicate a string up to n bytes.

mi_thread_done
void mi_thread_done()

Uninitialize mimalloc on a thread.

mi_thread_init
void mi_thread_init()

Initialize mimalloc on a thread.

mi_thread_stats_print
void mi_thread_stats_print(FILE* out_)

Print out heap statistics for this thread.

mi_usable_size
size_t mi_usable_size(const(void)* p)

Return the available bytes in a memory block.

mi_valloc
void* mi_valloc(size_t size)

mi prefixed implementations of various posix, unix, and C++ allocation functions

mi_version
int mi_version()

Get mimalloc version

mi_zalloc
void* mi_zalloc(size_t size)

Allocate zero-initialized size bytes.

mi_zalloc_aligned
void* mi_zalloc_aligned(size_t size, size_t alignment)

Allocate zero-initialized size bytes aligned by alignment.

mi_zalloc_aligned_at
void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset)

Allocate zero-initialized size bytes aligned by alignment at a specified offset.

mi_zalloc_small
void* mi_zalloc_small(size_t size)

Allocate a zero initialized small object.

Manifest constants

MI_MALLOC_VERSION
enum MI_MALLOC_VERSION;

The mimalloc version

MI_SMALL_SIZE_MAX
enum MI_SMALL_SIZE_MAX;

Maximum size allowed for small allocations in mi_malloc_small and mi_zalloc_small (usually 128*sizeof(void*) (= 1KB on 64-bit systems))

MI_SMALL_WSIZE_MAX
enum MI_SMALL_WSIZE_MAX;

Internal use

Structs

mi_heap_area_t
struct mi_heap_area_t

An area of heap space contains blocks of a single size.

mi_heap_t
struct mi_heap_t

Type of first-class heaps.

Meta