Plasma Engine  2.0
Loading...
Searching...
No Matches
AllocPolicyProxy.h
1#pragma once
2
3#include <Foundation/Basics.h>
4
11{
12public:
13 PL_FORCE_INLINE plAllocPolicyProxy(plAllocator* pParent)
14 : m_pParent(pParent)
15 {
16 PL_ASSERT_ALWAYS(m_pParent != nullptr, "Parent allocator must not be nullptr");
17 }
18
19 PL_FORCE_INLINE void* Allocate(size_t uiSize, size_t uiAlign) { return m_pParent->Allocate(uiSize, uiAlign); }
20
21 PL_FORCE_INLINE void* Reallocate(void* pPtr, size_t uiCurrentSize, size_t uiNewSize, size_t uiAlign)
22 {
23 return m_pParent->Reallocate(pPtr, uiCurrentSize, uiNewSize, uiAlign);
24 }
25
26 PL_FORCE_INLINE void Deallocate(void* pPtr) { m_pParent->Deallocate(pPtr); }
27
28 PL_FORCE_INLINE size_t AllocatedSize(const void* pPtr) { return m_pParent->AllocatedSize(pPtr); }
29
30 PL_ALWAYS_INLINE plAllocator* GetParent() const { return m_pParent; }
31
32private:
33 plAllocator* m_pParent;
34};
This Allocation policy redirects all operations to its parent.
Definition AllocPolicyProxy.h:11
Base class for all memory allocators.
Definition Allocator.h:23
virtual void * Allocate(size_t uiSize, size_t uiAlign, plMemoryUtils::DestructorFunction destructorFunc=nullptr)=0
Interface, do not use this directly, always use the new/delete macros below.
virtual size_t AllocatedSize(const void *pPtr)=0
Returns the number of bytes allocated at this address.