40#ifndef __AllocatorIntf_h
41#define __AllocatorIntf_h
43#include <TargConfig.h>
62typedef void* (*AllocatorIntf_Malloc)(
struct AllocatorIntf* o,
size_t* size);
75typedef void* (*AllocatorIntf_Realloc)(
122 void*
malloc(
size_t* size);
133 void*
realloc(
void* p,
size_t* size);
155#define AllocatorIntf_constructor(o, m, r, f) do { \
165#define AllocatorIntf_malloc(o, size) (o)->mallocCB(o, size)
172#define AllocatorIntf_realloc(o, memblock, size) \
173 ((o)->reallocCB ? (o)->reallocCB(o,memblock,size) : 0)
177#define AllocatorIntf_free(o, memblock) (o)->freeCB(o,memblock)
struct AllocatorIntf AllocatorIntf
Memory allocation and deallocation Interface class.
void *(* AllocatorIntf_Realloc)(struct AllocatorIntf *o, void *memblock, size_t *size)
Resize a block using the same allocator that allocated it.
Definition: AllocatorIntf.h:75
void *(* AllocatorIntf_Malloc)(struct AllocatorIntf *o, size_t *size)
Allocate a block using an allocator implementation.
Definition: AllocatorIntf.h:62
BA_API AllocatorIntf * AllocatorIntf_getDefault(void)
#define AllocatorIntf_realloc(o, memblock, size)
Dispatch a resize request.
Definition: AllocatorIntf.h:172
#define AllocatorIntf_malloc(o, size)
Dispatch an allocation request.
Definition: AllocatorIntf.h:165
void(* AllocatorIntf_Free)(struct AllocatorIntf *o, void *memblock)
Release a block.
Definition: AllocatorIntf.h:84
#define AllocatorIntf_constructor(o, m, r, f)
Install allocator callbacks without allocating any memory.
Definition: AllocatorIntf.h:155
BA_API char * baStrdup2(struct AllocatorIntf *a, const char *str)
Allocate a NUL-terminated copy of a string.
#define AllocatorIntf_free(o, memblock)
Dispatch a deallocation request.
Definition: AllocatorIntf.h:177
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:98
void * realloc(void *p, size_t *size)
Resize an allocation.
Definition: AllocatorIntf.h:204
void * malloc(size_t *size)
Allocate uninitialized storage.
Definition: AllocatorIntf.h:202
AllocatorIntf()
Leave callbacks uninitialized; initialize them before use.
Definition: AllocatorIntf.h:101
void free(void *p)
Release an allocation.
Definition: AllocatorIntf.h:206
void * realloc(void *p, size_t size)
Resize without returning the adjusted allocation size.
Definition: AllocatorIntf.h:138
static AllocatorIntf * getDefault(void)
Obtain the shared allocator backed by baMalloc, baRealloc and baFree.
Definition: AllocatorIntf.h:200
void * malloc(size_t size)
Allocate without returning the adjusted allocation size.
Definition: AllocatorIntf.h:126