CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
XAlloc (Memory Management)

Modules

 Allocation Flags
 
 Out-of-Memory Handling
 
 Core Allocation Functions
 
 Size Introspection
 
 Compatibility Interface
 

Functions

void xaFlush ()
 Flushes any deferred free() operations and returns as much memory to the OS as possible.
 

Detailed Description

The xalloc system provides a unified memory allocation interface with enhanced capabilities:

IMPORTANT: By default, xalloc guarantees memory allocation. If an allocation request cannot be satisfied (even after OOM handlers attempt to reclaim memory), the process will abort. You must explicitly specify XA_Opt or XA_Optional() for allocation requests that are allowed to fail and have proper failure handling.

// Basic allocation - guaranteed, will abort on failure
MyStruct *data = xaAllocStruct(MyStruct);
// Zero-filled allocation - guaranteed
uint8 *buffer = xaAlloc(1024, XA_Zero);
// Aligned allocation (64-byte boundary) - guaranteed
void *aligned = xaAlloc(4096, XA_Align(6));
// Optional allocation that may fail - MUST check for NULL
void *opt = xaAlloc(huge_size, XA_Opt);
if (!opt) {
// handle failure
}
// Resize existing allocation
xaResize(&buffer, new_size);
// Free with NULL assignment
xaDestroy(&data);
#define xaDestroy(ptr)
Definition xalloc.h:246
#define xaResize(ptr, size,...)
Definition xalloc.h:229
#define xaAllocStruct(typn,...)
Definition xalloc.h:213
#define xaAlloc(size,...)
Definition xalloc.h:199
#define XA_Align(exp)
Definition xalloc.h:88
#define XA_Opt
Definition xalloc.h:109
#define XA_Zero
Zero-fills returned memory.
Definition xalloc.h:91