4
#define INL_DEFAULT_ALIGNMENT 4
6
#define INL_SAFE_DELETE(mem) if(mem) \
11
#define INL_SAFE_DELETE_ARRAY(mem_array) if(mem_array) \
13
INLDELETEARRAY (mem_array); \
17
#define INL_SAFE_FREE(mem) if(mem) \
23
#if defined(INL_OS_WINDOWS)
24
#define INL_SYS_MEMORY_MALLOC(size) malloc(size)
25
#define INL_SYS_MEMORY_MEM_ALIGN(align, size) INL_SYS_MEMORY_MALLOC(size)
26
#define INL_SYS_MEMORY_REALLOC(ptr, size) realloc(ptr, size)
27
#define INL_SYS_MEMORY_REALLOC_ALIGN(ptr, size, align) realloc(ptr, size)
28
#define INL_SYS_MEMORY_FREE(ptr) free(ptr)
29
#define INL_SYS_MEMORY_PTR_SIZE(ptr) _msize(ptr)
30
#elif defined(INL_OS_LINUX)
31
#define INL_SYS_MEMORY_MALLOC(size) malloc(size)
32
#define INL_SYS_MEMORY_MEM_ALIGN(align, size) INL_SYS_MEMORY_MALLOC(size)
33
#define INL_SYS_MEMORY_REALLOC(ptr, size) realloc(ptr, size)
34
#define INL_SYS_MEMORY_REALLOC_ALIGN(ptr, size, align) realloc(ptr, size)
35
#define INL_SYS_MEMORY_FREE(ptr) free(ptr)
36
#define INL_SYS_MEMORY_PTR_SIZE(ptr) 0
38
#define INL_SYS_MEMORY_MALLOC(size) malloc(size)
39
#define INL_SYS_MEMORY_MEM_ALIGN(align, size) memalign(align, size)
40
#define INL_SYS_MEMORY_REALLOC(ptr, size) realloc(ptr, size)
41
#define INL_SYS_MEMORY_REALLOC_ALIGN(ptr, size, align) reallocalign(ptr, size, align)
42
#define INL_SYS_MEMORY_FREE(ptr) free(ptr)
43
#define INL_SYS_MEMORY_PTR_SIZE(ptr) 0
48
t_u32 Memcmp( const void* Buf1, const void* Buf2, t_u32 Count );
50
bool MemIsZero( const void* V, t_size Count );
52
void* Memmove( void* Dest, const void* Src, t_size Count );
54
void Memset( void* Dest, t_s32 C, t_size Count );
56
void Memzero( void* Dest, t_size Count );
58
void Memcpy( void* Dest, const void* Src, t_size Count );
60
void Memswap( void* Ptr1, void* Ptr2, t_size Size );
62
//! Check that the alignment is a power of two
63
bool IsMemoryAligned(void* data, t_u32 alignment);
65
void* Malloc(t_size Count, t_u32 Alignment = INL_DEFAULT_ALIGNMENT);
66
void* Realloc(void* Original, t_size Count, t_u32 Alignment = INL_DEFAULT_ALIGNMENT);
70
inline void inlFree( void* Original )
72
return free( Original );
75
/// Memory operation defines
76
#define INL_MEMOP_ALLOC 1
77
#define INL_MEMOP_NEW 2
78
#define INL_MEMOP_NEWARRAY 3
79
#define INL_MEMOP_FREE 4
80
#define INL_MEMOP_DELETE 5
81
#define INL_MEMOP_DELETEARRAY 6
84
#define INL_NEW_EXPLICIT(Allocator, ClassName, Comment, ParentPtr, File, Line, FunctionName) \
85
new(Memory::MemHelperAlloc< ClassName >(INL_MEMOP_NEW, \
93
FunctionName)) ClassName
97
#define INL_NEW(Allocator, ClassName, Comment, ParentPtr) INL_NEW_EXPLICIT(Allocator, ClassName, Comment, ParentPtr, __FILE__, __LINE__, __FUNCTION__)
98
#define inlNew(ClassName, Comment, ParentPtr) INL_NEW(GetDefaultMemoryAllocator(), ClassName, Comment, ParentPtr)
100
#define INL_DELETE_EXPLICIT(ptrObject, File, Line, FunctionName) \
101
Memory::MemHelperDelete(INL_MEMOP_DELETE, (ptrObject), \
105
#define INL_DELETE(ptrObject) INL_DELETE_EXPLICIT(ptrObject, __FILE__, __LINE__, __FUNCTION__)
106
#define inlDelete(ptrObject) INL_DELETE(ptrObject)
110
#define INL_ALLOC_EXPLICIT(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName) \
111
Memory::MemHelperAlloc< ObjectType >(INL_MEMOP_ALLOC, \
122
#define INL_ALLOC(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName) INL_ALLOC_EXPLICIT(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName)
123
#define inlMMAlloc(Allocator, ObjectType, Count, Comment, ParentPtr) INL_ALLOC(Allocator, ObjectType, Count, Comment, ParentPtr, __FILE__, __LINE__, __FUNCTION__)
126
#define INL_FREE_EXPLICIT(Allocator, Ptr, File, Line) \
127
Memory::MemHelperFastDelete( INL_MEMOP_FREE, \
133
#define INL_FREE(Allocator, Ptr) INL_FREE_EXPLICIT(Allocator, Ptr, __FILE__, __LINE__)
134
#define inlMMFree(Allocator, Ptr) INL_FREE(Allocator, Ptr)