ucx
UAP Common Extensions
Loading...
Searching...
No Matches
cx_array_reallocator_s Struct Reference

Defines a reallocation mechanism for arrays. More...

#include <array_list.h>

Data Fields

void *(* realloc )(void *array, size_t old_capacity, size_t new_capacity, size_t elem_size, struct cx_array_reallocator_s *alloc)
 Reallocates space for the given array.
 
const CxAllocatorallocator
 The allocator that shall be used for the reallocations.
 
const void * stack_ptr
 Optional pointer to stack memory if the array is originally located on the stack.
 

Detailed Description

Defines a reallocation mechanism for arrays.

You can create your own, use cx_array_reallocator(), or use the cx_array_default_reallocator.

Field Documentation

◆ realloc

void *(* cx_array_reallocator_s::realloc) (void *array, size_t old_capacity, size_t new_capacity, size_t elem_size, struct cx_array_reallocator_s *alloc)

Reallocates space for the given array.

Implementations are not required to free the original array. This allows reallocation of static or stack memory by allocating heap memory and copying the array contents; namely when stack_ptr in this struct is not NULL and array equals stack_ptr.

Parameters
arraythe array to reallocate
old_capacitythe old number of elements
new_capacitythe new number of elements
elem_sizethe size of each element
alloca reference to this allocator
Returns
a pointer to the reallocated memory or NULL on failure

The documentation for this struct was generated from the following file: