28
28
#define NUX_SAFE_DELETE(mem) if(mem) \
33
33
#define NUX_SAFE_DELETE_ARRAY(mem_array) if(mem_array) \
35
INLDELETEARRAY (mem_array); \
35
delete[](mem_array); \
39
#define NUX_SAFE_FREE(mem) if(mem) \
45
#if defined(NUX_OS_WINDOWS)
46
#define NUX_SYS_MEMORY_MALLOC(size) malloc(size)
47
#define NUX_SYS_MEMORY_MEM_ALIGN(align, size) NUX_SYS_MEMORY_MALLOC(size)
48
#define NUX_SYS_MEMORY_REALLOC(ptr, size) realloc(ptr, size)
49
#define NUX_SYS_MEMORY_REALLOC_ALIGN(ptr, size, align) realloc(ptr, size)
50
#define NUX_SYS_MEMORY_FREE(ptr) free(ptr)
51
#define NUX_SYS_MEMORY_PTR_SIZE(ptr) _msize(ptr)
52
#elif defined(NUX_OS_LINUX)
53
#define NUX_SYS_MEMORY_MALLOC(size) malloc(size)
54
#define NUX_SYS_MEMORY_MEM_ALIGN(align, size) NUX_SYS_MEMORY_MALLOC(size)
55
#define NUX_SYS_MEMORY_REALLOC(ptr, size) realloc(ptr, size)
56
#define NUX_SYS_MEMORY_REALLOC_ALIGN(ptr, size, align) realloc(ptr, size)
57
#define NUX_SYS_MEMORY_FREE(ptr) free(ptr)
58
#define NUX_SYS_MEMORY_PTR_SIZE(ptr) 0
86
inline void inlFree ( void *Original )
88
return free ( Original );
91
/// Memory operation defines
92
#define NUX_MEMOP_ALLOC 1
93
#define NUX_MEMOP_NEW 2
94
#define NUX_MEMOP_NEWARRAY 3
95
#define NUX_MEMOP_FREE 4
96
#define NUX_MEMOP_DELETE 5
97
#define NUX_MEMOP_DELETEARRAY 6
100
#define NUX_NEW_EXPLICIT(Allocator, ClassName, Comment, ParentPtr, File, Line, FunctionName) \
101
new(Memory::MemHelperAlloc< ClassName >(NUX_MEMOP_NEW, \
109
FunctionName)) ClassName
113
#define NUX_NEW(Allocator, ClassName, Comment, ParentPtr) NUX_NEW_EXPLICIT(Allocator, ClassName, Comment, ParentPtr, __FILE__, __LINE__, __FUNCTION__)
114
#define inlNew(ClassName, Comment, ParentPtr) NUX_NEW(GetDefaultMemoryAllocator(), ClassName, Comment, ParentPtr)
116
#define NUX_DELETE_EXPLICIT(ptrObject, File, Line, FunctionName) \
117
Memory::MemHelperDelete(NUX_MEMOP_DELETE, (ptrObject), \
121
#define NUX_DELETE(ptrObject) NUX_DELETE_EXPLICIT(ptrObject, __FILE__, __LINE__, __FUNCTION__)
122
#define inlDelete(ptrObject) NUX_DELETE(ptrObject)
126
#define NUX_ALLOC_EXPLICIT(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName) \
127
Memory::MemHelperAlloc< ObjectType >(NUX_MEMOP_ALLOC, \
138
#define NUX_ALLOC(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName) NUX_ALLOC_EXPLICIT(Allocator, ObjectType, Count, Comment, ParentPtr, File, Line, FunctionName)
139
#define inlMMAlloc(Allocator, ObjectType, Count, Comment, ParentPtr) NUX_ALLOC(Allocator, ObjectType, Count, Comment, ParentPtr, __FILE__, __LINE__, __FUNCTION__)
142
#define NUX_FREE_EXPLICIT(Allocator, Ptr, File, Line) \
143
Memory::MemHelperFastDelete( NUX_MEMOP_FREE, \
149
#define NUX_FREE(Allocator, Ptr) NUX_FREE_EXPLICIT(Allocator, Ptr, __FILE__, __LINE__)
150
#define inlMMFree(Allocator, Ptr) NUX_FREE(Allocator, Ptr)
152
65
#endif // NMEMORY_H