mi-malloc 3.7/2.5/1.15
Loading...
Searching...
No Matches
Zero initialized re-allocation

Re-allocation where the expanded part is initialized to zero. More...

Functions

void * mi_rezalloc (void *p, size_t oldsize, size_t newsize)
 Re-allocate memory to newsize bytes, with the memory from oldsize initialized to zero.
void * mi_recalloc (void *p, size_t oldcount, size_t newcount, size_t size)
 Re-allocate memory to newcount elements of size bytes, with the elements from oldcount initialized to zero.
void * mi_rezalloc_aligned (void *p, size_t oldsize, size_t newsize, size_t alignment)
 As mi_rezalloc() but the returned block is aligned to alignment.
void * mi_rezalloc_aligned_at (void *p, size_t oldsize, size_t newsize, size_t alignment, size_t offset)
 As mi_rezalloc() but the returned block is aligned by alignment at a specified offset.
void * mi_recalloc_aligned (void *p, size_t oldcount, size_t newcount, size_t size, size_t alignment)
 As mi_recalloc() but the returned block is aligned to alignment.
void * mi_recalloc_aligned_at (void *p, size_t oldcount, size_t newcount, size_t size, size_t alignment, size_t offset)
 As mi_recalloc() but the returned block is aligned by alignment at a specified offset.
void * mi_heap_rezalloc (mi_heap_t *heap, void *p, size_t oldsize, size_t newsize)
 As mi_rezalloc() but allocates in a specific heap.
void * mi_heap_recalloc (mi_heap_t *heap, void *p, size_t oldcount, size_t newcount, size_t size)
 As mi_recalloc() but allocates in a specific heap.
void * mi_heap_rezalloc_aligned (mi_heap_t *heap, void *p, size_t oldsize, size_t newsize, size_t alignment)
 As mi_rezalloc_aligned() but allocates in a specific heap.
void * mi_heap_rezalloc_aligned_at (mi_heap_t *heap, void *p, size_t oldsize, size_t newsize, size_t alignment, size_t offset)
 As mi_rezalloc_aligned_at() but allocates in a specific heap.
void * mi_heap_recalloc_aligned (mi_heap_t *heap, void *p, size_t oldcount, size_t newcount, size_t size, size_t alignment)
 As mi_recalloc_aligned() but allocates in a specific heap.
void * mi_heap_recalloc_aligned_at (mi_heap_t *heap, void *p, size_t oldcount, size_t newcount, size_t size, size_t alignment, size_t offset)
 As mi_recalloc_aligned_at() but allocates in a specific heap.

Detailed Description

Re-allocation where the expanded part is initialized to zero.

Note: the previous versions of these functions did not take the old size (or count) and could only be used on memory that was originally allocated with zero initialization (e.g. mi_calloc, mi_zalloc, etc.). These deprecated functions can still be called by putting parentheses around the function name, e.g. (mi_rezalloc)(p,newsize).

The re-allocated block preserves the first min(oldsize,newsize) bytes of p, and the rest of the block is initialized to zero (up to its usable size). The block p does not need to be zero initialized, and the old size is clamped to the usable size of p (see mi_usable_size()).

Function Documentation

◆ mi_heap_recalloc()

void * mi_heap_recalloc ( mi_heap_t * heap,
void * p,
size_t oldcount,
size_t newcount,
size_t size )

As mi_recalloc() but allocates in a specific heap.

◆ mi_heap_recalloc_aligned()

void * mi_heap_recalloc_aligned ( mi_heap_t * heap,
void * p,
size_t oldcount,
size_t newcount,
size_t size,
size_t alignment )

As mi_recalloc_aligned() but allocates in a specific heap.

◆ mi_heap_recalloc_aligned_at()

void * mi_heap_recalloc_aligned_at ( mi_heap_t * heap,
void * p,
size_t oldcount,
size_t newcount,
size_t size,
size_t alignment,
size_t offset )

As mi_recalloc_aligned_at() but allocates in a specific heap.

◆ mi_heap_rezalloc()

void * mi_heap_rezalloc ( mi_heap_t * heap,
void * p,
size_t oldsize,
size_t newsize )

As mi_rezalloc() but allocates in a specific heap.

◆ mi_heap_rezalloc_aligned()

void * mi_heap_rezalloc_aligned ( mi_heap_t * heap,
void * p,
size_t oldsize,
size_t newsize,
size_t alignment )

As mi_rezalloc_aligned() but allocates in a specific heap.

◆ mi_heap_rezalloc_aligned_at()

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

As mi_rezalloc_aligned_at() but allocates in a specific heap.

◆ mi_recalloc()

void * mi_recalloc ( void * p,
size_t oldcount,
size_t newcount,
size_t size )

Re-allocate memory to newcount elements of size bytes, with the elements from oldcount initialized to zero.

Parameters
pPointer to a previously allocated block (or NULL).
oldcountThe old number of elements in p (ignored if p is NULL).
newcountThe new number of elements.
sizeThe size of each element.
Returns
A pointer to a re-allocated block of newcount * size bytes, or NULL if out of memory or if newcount * size overflows.

If there is no overflow, it behaves exactly like mi_rezalloc(p,oldcount*size,newcount*size).

See also
mi_reallocn()
recallocarray() (on BSD).

◆ mi_recalloc_aligned()

void * mi_recalloc_aligned ( void * p,
size_t oldcount,
size_t newcount,
size_t size,
size_t alignment )

As mi_recalloc() but the returned block is aligned to alignment.

◆ mi_recalloc_aligned_at()

void * mi_recalloc_aligned_at ( void * p,
size_t oldcount,
size_t newcount,
size_t size,
size_t alignment,
size_t offset )

As mi_recalloc() but the returned block is aligned by alignment at a specified offset.

◆ mi_rezalloc()

void * mi_rezalloc ( void * p,
size_t oldsize,
size_t newsize )

Re-allocate memory to newsize bytes, with the memory from oldsize initialized to zero.

Parameters
pPointer to a previously allocated block (or NULL).
oldsizeThe old size of p (ignored if p is NULL).
newsizeThe new size in bytes.
Returns
A pointer to a re-allocated block of newsize bytes, or NULL if out of memory (in which case p is not freed).

If p is NULL, it behaves as mi_zalloc(newsize).

See also
mi_realloc()

◆ mi_rezalloc_aligned()

void * mi_rezalloc_aligned ( void * p,
size_t oldsize,
size_t newsize,
size_t alignment )

As mi_rezalloc() but the returned block is aligned to alignment.

◆ mi_rezalloc_aligned_at()

void * mi_rezalloc_aligned_at ( void * p,
size_t oldsize,
size_t newsize,
size_t alignment,
size_t offset )

As mi_rezalloc() but the returned block is aligned by alignment at a specified offset.