52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
#include <c_Allocator.h>
|
|
#include <stdlib.h>
|
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
/* */
|
|
|
|
C_STATIC_FORCE_INLINE
|
|
void* c_DefaultAllocator_Alloc(c_size_t nBytes, void* ud) {
|
|
C_UNUSED(ud);
|
|
return malloc(nBytes);
|
|
}
|
|
|
|
C_STATIC_FORCE_INLINE
|
|
C_ALLOCATOR_REALLOC_FN(c_DefaultAllocator_Realloc) {
|
|
C_UNUSED(ud);
|
|
C_UNUSED(nOldSize);
|
|
return realloc(ptr, nNewSize);
|
|
}
|
|
|
|
C_STATIC_FORCE_INLINE
|
|
void* c_DefaultAllocator_Calloc(c_size_t nCount, c_size_t nBytes, void* ud) {
|
|
C_UNUSED(ud);
|
|
return calloc(nCount, nBytes);
|
|
}
|
|
C_STATIC_FORCE_INLINE
|
|
void c_DefaultAllocator_Free(void* ptr, void* ud) {
|
|
C_UNUSED(ud);
|
|
if (ptr) {
|
|
free(ptr);
|
|
}
|
|
}
|
|
|
|
C_STATIC_FORCE_INLINE
|
|
void c_DefaultAllocator_Dtor(void* ud) {
|
|
C_UNUSED(ud);
|
|
}
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
/* */
|
|
|
|
|
|
c_Allocator_t c_DefaultAllocator=(c_Allocator_t){
|
|
c_DefaultAllocator_Alloc,
|
|
c_DefaultAllocator_Realloc,
|
|
c_DefaultAllocator_Calloc,
|
|
c_DefaultAllocator_Free,
|
|
c_DefaultAllocator_Dtor,
|
|
0
|
|
};
|
|
|