mi-malloc 3.5/2.5/1.15
 
Loading...
Searching...
No Matches
Constant size allocation

Inlined definitions for onstant size allocation and freeing. More...

Functions

void * mi_malloc_csize (size_t size)
 v3: Allocate a constant size object.
 
void * mi_zalloc_csize (size_t size)
 
void * mi_theap_malloc_csize (mi_theap_t *theap, size_t size)
 
void * mi_theap_zalloc_csize (mi_theap_t *theap, size_t size)
 
void mi_free_csize (void *p, size_t size)
 v3: Free a pointer with a known constant size.
 
void mi_free_csize_nonnull (void *p, size_t size)
 v3: Free a non-null pointer with a known constant size.
 

Detailed Description

Inlined definitions for onstant size allocation and freeing.

If the size is constant, it can pick statically between mi_malloc() and mi_malloc_small(). For example:

long* p = (long*)mi_malloc_csize(sizeof(long))
void * mi_malloc_csize(size_t size)
v3: Allocate a constant size object.

On v3 these can improve performance. This is especially useful for compilers and runtimes where the the size is often statically known. These functions can be used even when the size is not constant but then there is no performance benefit.

Function Documentation

◆ mi_free_csize()

void mi_free_csize ( void * p,
size_t size )

v3: Free a pointer with a known constant size.

Parameters
pThe pointer to the allocated block (or NULL )
sizeThe size with which the pointer was allocated.
See also
mi_malloc_csize()
mi_free_size()
mi_free_size_nonnull()

◆ mi_free_csize_nonnull()

void mi_free_csize_nonnull ( void * p,
size_t size )

v3: Free a non-null pointer with a known constant size.

Parameters
pThe pointer to the allocated block (cannot be NULL !)
sizeThe size with which the pointer was allocated.
See also
mi_malloc_csize()
mi_free_size()
mi_free_size_nonnull()

◆ mi_malloc_csize()

void * mi_malloc_csize ( size_t size)

v3: Allocate a constant size object.

Parameters
sizeA (compile-time) constant size.
Returns
A pointer to an allocated block of size size bytes.
See also
mi_free_csize()
mi_malloc()

◆ mi_theap_malloc_csize()

void * mi_theap_malloc_csize ( mi_theap_t * theap,
size_t size )

◆ mi_theap_zalloc_csize()

void * mi_theap_zalloc_csize ( mi_theap_t * theap,
size_t size )

◆ mi_zalloc_csize()

void * mi_zalloc_csize ( size_t size)