Start implementing allocator abstraction
This commit is contained in:
parent
7039b5437a
commit
9ec123c41b
31
mem/include/allocator/mem_allocator.h
Normal file
31
mem/include/allocator/mem_allocator.h
Normal 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
|
Loading…
Reference in New Issue
Block a user