Start implementing allocator abstraction

This commit is contained in:
Abdelrahman Said 2024-03-24 19:24:54 +00:00
parent 7039b5437a
commit 9ec123c41b

View File

@ -0,0 +1,31 @@
#ifndef MEM_ALLOCATOR_H
#define MEM_ALLOCATOR_H
#include "aliases.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef void *(MemAllocFunc)(u64 size, void *alloc_obj);
typedef void *(MemAllocAlignedFunc)(u64 size, u64 alignment, void *alloc_obj);
typedef void *(MemReallocFunc)(void *ptr, u64 size, void *alloc_obj);
typedef void *(MemReallocAlignedFunc)(void *ptr, u64 size, u64 alignment,
void *alloc_obj);
typedef void(MemFreeFunc)(void *ptr, void *alloc_obj);
typedef struct allocator Allocator;
struct allocator {
void *obj;
MemAllocFunc *alloc;
MemAllocAlignedFunc *alloc_aligned;
MemReallocFunc *realloc;
MemReallocAlignedFunc *realloc_aligned;
MemFreeFunc *free;
};
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !MEM_ALLOCATOR_H