33#ifndef UCX_ALLOCATOR_H
34#define UCX_ALLOCATOR_H
194#define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n)
212#define cx_reallocatearray(mem, nmemb, size) \
213 cx_reallocatearray_((void**)(mem), nmemb, size)
343#define cxReallocate(allocator, mem, n) \
344 cxReallocate_(allocator, (void**)(mem), n)
394#define cxReallocateArray(allocator, mem, nmemb, size) \
395 cxReallocateArray_(allocator, (void**) (mem), nmemb, size)
int cxReallocate_(const CxAllocator *allocator, void **mem, size_t n)
Reallocate a previously allocated block and changes the pointer in-place, if necessary.
void(* cx_destructor_func2)(void *data, void *memory)
Function pointer type for destructor functions.
Definition allocator.h:129
int cx_reallocatearray_(void **mem, size_t nmemb, size_t size)
Reallocate a previously allocated block and changes the pointer in-place, if necessary.
void cxFree(const CxAllocator *allocator, void *mem)
Free a block allocated by this allocator.
void(* cx_destructor_func)(void *memory)
Function pointer type for destructor functions.
Definition allocator.h:116
void * cxMalloc(const CxAllocator *allocator, size_t n)
Allocate n bytes of memory.
void * cxReallocArray(const CxAllocator *allocator, void *mem, size_t nmemb, size_t size)
Reallocate the previously allocated block in mem, making the new block n bytes long.
int cx_reallocate_(void **mem, size_t n)
Reallocate a previously allocated block and changes the pointer in-place, if necessary.
const CxAllocator *const cxDefaultAllocator
A default allocator using standard library malloc() etc.
void * cxCalloc(const CxAllocator *allocator, size_t nmemb, size_t size)
Allocate nmemb elements of n bytes each, all initialized to zero.
void * cxRealloc(const CxAllocator *allocator, void *mem, size_t n)
Reallocate the previously allocated block in mem, making the new block n bytes long.
int cxReallocateArray_(const CxAllocator *allocator, void **mem, size_t nmemb, size_t size)
Reallocate a previously allocated block and changes the pointer in-place, if necessary.
Common definitions and feature checks.
#define cx_attr_export
Only used for building Windows DLLs.
Definition common.h:285
#define cx_attr_allocsize(...)
Specifies the parameters from which the allocation size is calculated.
Definition common.h:178
#define cx_attr_nonnull
All pointer arguments must be non-NULL.
Definition common.h:136
#define cx_attr_nodiscard
Warn about discarded return value.
Definition common.h:265
#define cx_attr_malloc
The attributed function always returns freshly allocated memory.
Definition common.h:151
#define cx_attr_dealloc_ucx
Shortcut to specify cxFree() as deallocator.
Definition common.h:173
#define cx_attr_nonnull_arg(...)
The specified pointer arguments must be non-NULL.
Definition common.h:141
The class definition for an allocator.
Definition allocator.h:45
Structure holding the data for an allocator.
Definition allocator.h:84
void * data
A pointer to the data this allocator uses.
Definition allocator.h:92
cx_allocator_class * cl
A pointer to the instance of the allocator class.
Definition allocator.h:88