This commit is contained in:
Hongze Cheng 2021-09-27 17:08:02 +08:00
parent 773db063d2
commit eec3543c09
1 changed files with 8 additions and 4 deletions

View File

@ -35,10 +35,14 @@ typedef struct {
SMemAllocatorIf interface;
} SMemAllocator;
#define amalloc(allocator, size) (*((allocator)->interface.malloc))((allocator)->impl, size)
#define acalloc(allocator, nmemb, size) (*((allocator)->interface.calloc))((allocator)->impl, nmemb, size)
#define arealloc(allocator, ptr, size) (*((allocator)->interface.realloc))((allocator)->impl, ptr, size)
#define afree(allocator, ptr, size) (*((allocator)->interface.free))((allocator)->impl, ptr, size)
#define amalloc(allocator, size) \
((allocator) ? (*((allocator)->interface.malloc))((allocator)->impl, (size)) : malloc(size))
#define acalloc(allocator, nmemb, size) \
((allocator) ? (*((allocator)->interface.calloc))((allocator)->impl, (nmemb), (size)) : calloc((nmemb), (size)))
#define arealloc(allocator, ptr, size) \
((allocator) ? (*((allocator)->interface.realloc))((allocator)->impl, (ptr), (size)) : realloc((ptr), (size)))
#define afree(allocator, ptr, size) \
((allocator) ? (*((allocator)->interface.free))((allocator)->impl, (ptr), (size)) : free(ptr))
#ifdef __cplusplus
}