ezEngine  Milestone 9
AllocatorBase.h File Reference
#include <Foundation/Types/ArrayPtr.h>
#include <Foundation/Types/Id.h>
#include <utility>
#include <Foundation/Memory/Implementation/AllocatorBase_inl.h>

Go to the source code of this file.

Classes

class  ezAllocatorBase
 Base class for all memory allocators. More...
 
struct  ezAllocatorBase::Stats
 

Macros

#define EZ_NEW(allocator, type, ...)
 creates a new instance of type using the given allocator More...
 
#define EZ_DELETE(allocator, ptr)
 deletes the instance stored in ptr using the given allocator and sets ptr to nullptr More...
 
#define EZ_NEW_ARRAY(allocator, type, count)   ezInternal::CreateArray<type>(allocator, count)
 creates a new array of type using the given allocator with count elements, calls default constructor for non-POD types
 
#define EZ_DELETE_ARRAY(allocator, arrayPtr)
 Calls destructor on every element for non-POD types and deletes the array stored in arrayPtr using the given allocator. More...
 
#define EZ_NEW_RAW_BUFFER(allocator, type, count)   ezInternal::CreateRawBuffer<type>(allocator, count)
 creates a raw buffer of type using the given allocator with count elements, but does NOT call the default constructor
 
#define EZ_DELETE_RAW_BUFFER(allocator, ptr)
 deletes a raw buffer stored in ptr using the given allocator, but does NOT call destructor More...
 
#define EZ_EXTEND_RAW_BUFFER(allocator, ptr, oldSize, newSize)   ezInternal::ExtendRawBuffer(ptr, allocator, oldSize, newSize)
 extends a given raw buffer to the new size, taking care of calling constructors / assignment operators.
 
#define EZ_DEFAULT_NEW(type, ...)   EZ_NEW(ezFoundation::GetDefaultAllocator(), type, __VA_ARGS__)
 creates a new instance of type using the default allocator
 
#define EZ_DEFAULT_DELETE(ptr)   EZ_DELETE(ezFoundation::GetDefaultAllocator(), ptr)
 deletes the instance stored in ptr using the default allocator and sets ptr to nullptr
 
#define EZ_DEFAULT_NEW_ARRAY(type, count)   EZ_NEW_ARRAY(ezFoundation::GetDefaultAllocator(), type, count)
 creates a new array of type using the default allocator with count elements, calls default constructor for non-POD types
 
#define EZ_DEFAULT_DELETE_ARRAY(arrayPtr)   EZ_DELETE_ARRAY(ezFoundation::GetDefaultAllocator(), arrayPtr)
 calls destructor on every element for non-POD types and deletes the array stored in arrayPtr using the default allocator
 
#define EZ_DEFAULT_NEW_RAW_BUFFER(type, count)   EZ_NEW_RAW_BUFFER(ezFoundation::GetDefaultAllocator(), type, count)
 creates a raw buffer of type using the default allocator with count elements, but does NOT call the default constructor
 
#define EZ_DEFAULT_DELETE_RAW_BUFFER(ptr)   EZ_DELETE_RAW_BUFFER(ezFoundation::GetDefaultAllocator(), ptr)
 deletes a raw buffer stored in ptr using the default allocator, but does NOT call destructor
 

Typedefs

typedef ezGenericId< 24, 8 > ezAllocatorId
 

Macro Definition Documentation

◆ EZ_DELETE

#define EZ_DELETE (   allocator,
  ptr 
)
Value:
{ \
ezInternal::Delete(allocator, ptr); \
ptr = nullptr; \
}

deletes the instance stored in ptr using the given allocator and sets ptr to nullptr

◆ EZ_DELETE_ARRAY

#define EZ_DELETE_ARRAY (   allocator,
  arrayPtr 
)
Value:
{ \
ezInternal::DeleteArray(allocator, arrayPtr); \
arrayPtr.Clear(); \
}

Calls destructor on every element for non-POD types and deletes the array stored in arrayPtr using the given allocator.

◆ EZ_DELETE_RAW_BUFFER

#define EZ_DELETE_RAW_BUFFER (   allocator,
  ptr 
)
Value:
{ \
ezInternal::DeleteRawBuffer(allocator, ptr); \
ptr = nullptr; \
}

deletes a raw buffer stored in ptr using the given allocator, but does NOT call destructor

◆ EZ_NEW

#define EZ_NEW (   allocator,
  type,
  ... 
)
Value:
new ((allocator)->Allocate(sizeof(type), EZ_ALIGNMENT_OF(type), ezMemoryUtils::MakeDestructorFunction<type>())) type(__VA_ARGS__), \
(allocator))
Definition: AllocatorBase_inl.h:13

creates a new instance of type using the given allocator