mi-malloc 3.6/2.5/1.15
Loading...
Searching...
No Matches
Allocation with Block Sizes

v3: Allocate or free memory while reporting the allocator's block size in bytes. More...

Functions

void * mi_umalloc (size_t size, size_t *block_size)
 Allocate size bytes and report the block size through block_size.
void * mi_ucalloc (size_t count, size_t size, size_t *block_size)
 Allocate count zero-initialized elements of size bytes and report the block size.
void * mi_urealloc (void *p, size_t newsize, size_t *block_size_pre, size_t *block_size_post)
 Reallocate p to newsize bytes and report the old and new block sizes.
void mi_ufree (void *p, size_t *block_size)
 Free p and report its block size, or 0 if p is NULL.
void * mi_umalloc_aligned (size_t size, size_t alignment, size_t *block_size)
 As mi_malloc_aligned(), additionally reporting the block size on success.
void * mi_uzalloc_aligned (size_t size, size_t alignment, size_t *block_size)
 As mi_zalloc_aligned(), additionally reporting the block size on success.
void * mi_umalloc_small (size_t size, size_t *block_size)
 As mi_malloc_small(), additionally reporting the block size on success.
void * mi_uzalloc_small (size_t size, size_t *block_size)
 As mi_zalloc_small(), additionally reporting the block size on success.

Detailed Description

v3: Allocate or free memory while reporting the allocator's block size in bytes.

Reported sizes may include padding or alignment overhead and are not a guarantee of writable capacity. Size output pointers may be NULL. Allocation size outputs are only valid on success; they need not be cleared on failure.

Function Documentation

◆ mi_ucalloc()

void * mi_ucalloc ( size_t count,
size_t size,
size_t * block_size )

Allocate count zero-initialized elements of size bytes and report the block size.

Returns
The allocation, or NULL on failure or multiplication overflow.
See also
mi_calloc()

◆ mi_ufree()

void mi_ufree ( void * p,
size_t * block_size )

Free p and report its block size, or 0 if p is NULL.

See also
mi_free()

◆ mi_umalloc()

void * mi_umalloc ( size_t size,
size_t * block_size )

Allocate size bytes and report the block size through block_size.

Returns
The allocation, or NULL on failure.
See also
mi_malloc()

◆ mi_umalloc_aligned()

void * mi_umalloc_aligned ( size_t size,
size_t alignment,
size_t * block_size )

As mi_malloc_aligned(), additionally reporting the block size on success.

◆ mi_umalloc_small()

void * mi_umalloc_small ( size_t size,
size_t * block_size )

As mi_malloc_small(), additionally reporting the block size on success.

size must not exceed MI_SMALL_SIZE_MAX.

◆ mi_urealloc()

void * mi_urealloc ( void * p,
size_t newsize,
size_t * block_size_pre,
size_t * block_size_post )

Reallocate p to newsize bytes and report the old and new block sizes.

block_size_pre is 0 for NULL input; block_size_post is valid on success.

Returns
The reallocated block, or NULL on failure without freeing p.
See also
mi_realloc()

◆ mi_uzalloc_aligned()

void * mi_uzalloc_aligned ( size_t size,
size_t alignment,
size_t * block_size )

As mi_zalloc_aligned(), additionally reporting the block size on success.

◆ mi_uzalloc_small()

void * mi_uzalloc_small ( size_t size,
size_t * block_size )

As mi_zalloc_small(), additionally reporting the block size on success.

size must not exceed MI_SMALL_SIZE_MAX.