static CriUint32 usermem_allocated_size = 0;
void userMem_Initialize(void)
{
usermem_allocated_size = 0;
}
void userMem_Finalize(void)
{
if (usermem_allocated_size != 0) {
}
}
CriUint32 userMem_GetAllocatedMemorySize(void)
{
return usermem_allocated_size;
}
void *userMem_Alloc(void *obj, CriUint32 size)
{
void* mem = malloc(size + sizeof(CriUint32));
void* ptr = CRI_NULL;
if (mem != CRI_NULL) {
usermem_allocated_size += size;
ptr = (void*)((CriUintPtr)mem + sizeof(CriUint32));
*(CriUint32*)mem = size;
}
return ptr;
}
void userMem_Free(void *obj, void *buf)
{
Uint32 size;
void* mem;
if (buf != NULL) {
mem = (void*)((CriUintPtr)buf - sizeof(CriUint32));
size = *(CriUint32*)mem;
usermem_allocated_size -= size;
free(mem);
}
}
main()
{
userMem_Initialize();
:
:
:
userMem_Finalize();
}
void criAtomEx_Finalize(void)
Finalize the library
CriBool criAtomEx_Initialize(const CriAtomExConfig *config, void *work, CriSint32 work_size)
Initialize the library
#define criAtomEx_SetUserAllocator(p_malloc_func, p_free_func, p_obj)
Register a custom memory allocator
Definition: cri_le_atom_ex.h:309