|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | xaAlloc(size, ...) _xaAlloc(size, opt_flags(__VA_ARGS__)) |
| #define | xaAllocStruct(typn, ...) (typn*)_xaAlloc(sizeof(typn), opt_flags(__VA_ARGS__)) |
| #define | xaResize(ptr, size, ...) (_xa_ptr_ptr_verify(ptr), _xaResize((void**)(ptr), size, opt_flags(__VA_ARGS__))) |
| #define | xaDestroy(ptr) (_xa_ptr_ptr_verify(ptr), _xaDestroy((void**)(ptr))) |
Functions | |
| void | xaFree (void *ptr) |
Primary memory allocation and deallocation functions.
| #define xaAlloc | ( | size, | |
| ... | |||
| ) | _xaAlloc(size, opt_flags(__VA_ARGS__)) |
void *xaAlloc(size_t size, [flags])
Allocate memory of at least size bytes.
Flags can be combined:
| size | Number of bytes to allocate |
| ... | (flags) Optional allocation flags |
| #define xaAllocStruct | ( | typn, | |
| ... | |||
| ) | (typn*)_xaAlloc(sizeof(typn), opt_flags(__VA_ARGS__)) |
typename *xaAllocStruct(typn, [flags])
Convenience macro to allocate a struct-sized block of memory.
Flags can be combined:
| typn | Type name of the struct to allocate |
| ... | (flags) Optional allocation flags |
| #define xaDestroy | ( | ptr | ) | (_xa_ptr_ptr_verify(ptr), _xaDestroy((void**)(ptr))) |
Destroys the pointer. This frees *ptr (if it is non-NULL) and sets it to NULL.
| ptr | Pointer to pointer to free and set to NULL |
| #define xaResize | ( | ptr, | |
| size, | |||
| ... | |||
| ) | (_xa_ptr_ptr_verify(ptr), _xaResize((void**)(ptr), size, opt_flags(__VA_ARGS__))) |
bool xaResize(void **ptr, size_t size, [flags])
Reallocate ptr to be at least size bytes large, copying it if necessary. If ptr points to NULL, allocates new memory.
| ptr | Pointer to pointer to reallocate |
| size | New size in bytes |
| ... | (flags) Optional allocation flags (XA_Opt to allow failure) |
| void xaFree | ( | void * | ptr | ) |
Frees the memory at ptr. Does nothing if ptr is NULL.
| ptr | Pointer to memory to free |
Referenced by xa_free().