summaryrefslogtreecommitdiffstats
path: root/Primitives/interface
diff options
context:
space:
mode:
Diffstat (limited to 'Primitives/interface')
-rw-r--r--Primitives/interface/MemoryAllocator.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/Primitives/interface/MemoryAllocator.h b/Primitives/interface/MemoryAllocator.h
index 734f507c..5fdf3b32 100644
--- a/Primitives/interface/MemoryAllocator.h
+++ b/Primitives/interface/MemoryAllocator.h
@@ -38,9 +38,8 @@ DILIGENT_BEGIN_NAMESPACE(Diligent)
#if DILIGENT_CPP_INTERFACE
/// Base interface for a raw memory allocator
-class IMemoryAllocator
+struct IMemoryAllocator
{
-public:
/// Allocates block of memory
virtual void* Allocate(size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) = 0;
@@ -50,6 +49,33 @@ public:
#else
+struct IMemoryAllocator;
+
+// clang-format off
+
+struct IMemoryAllocatorMethods
+{
+ void* (*Allocate) (struct IMemoryAllocator*, size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber);
+ void (*Free) (struct IMemoryAllocator*, void* Ptr);
+};
+
+struct IMemoryAllocatorVtbl
+{
+ struct IMemoryAllocatorMethods MemoryAllocator;
+};
+
+// clang-format on
+
+typedef struct IMemoryAllocator
+{
+ struct IMemoryAllocatorVtbl* pVtbl;
+} IMemoryAllocator;
+
+// clang-format off
+
+# define IMemoryAllocator_Allocate(This, ...) (This)->pVtbl->MemoryAllocator.Allocate((IMemoryAllocator*)(This), __VA_ARGS__)
+# define IMemoryAllocator_Free(This, ...) (This)->pVtbl->MemoryAllocator.Free ((IMemoryAllocator*)(This), __VA_ARGS__)
+
#endif
DILIGENT_END_NAMESPACE // namespace Diligent