Adapt interface:wq

This commit is contained in:
Kim Kulling
2025-12-18 11:12:14 +01:00
parent 7610b184eb
commit 56414694b3
+11 -5
View File
@@ -45,19 +45,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stddef.h>
typedef void* (*alloc_func)(size_t size);
typedef void* (*realloc_func)(void* ptr, size_t size);
typedef void (*free_func)(void* ptr);
struct Allocator {
alloc_func alloc{nullptr};
realloc_func realloc{nullptr};
free_func free{nullptr};
static alloc_func alloc{nullptr};
static free_func free{nullptr};
static void init(alloc_func alloc_fn, free_func free_fn) {
alloc = alloc_fn;
free = free_fn;
}
};
static void aiRegisterAllocator(alloc_func alloc_fn, free_func free_fn) {
Allocator::init(alloc_fn, free_fn);
}
#define AI_NEW(ai_type,...) new ai_type(__VA_ARGS__)
#define AI_NEW_ARRAY(ai_type,count) new ai_type[count]()
#define AI_DELETE(ptr) delete ptr
#define AI_DELETE_ARRAY(ptr) delete[] ptr
#endif // AI_ALLOCATOR_H_INC