53#define OGDF_MM(Alloc) \
55 static void* operator new(size_t nBytes) { \
56 if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
57 return Alloc::allocate(nBytes); \
59 return ogdf::MallocMemoryAllocator::allocate(nBytes); \
62 static void operator delete(void* p, size_t nBytes) { \
63 if (OGDF_LIKELY(p != 0)) { \
64 if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
65 Alloc::deallocate(nBytes, p); \
67 ogdf::MallocMemoryAllocator::deallocate(nBytes, p); \
70 static void* operator new(size_t, void* p) { return p; } \
71 static void operator delete(void*, void*) { }
73#ifdef OGDF_MEMORY_MALLOC_TS
74# define OGDF_ALLOCATOR ogdf::MallocMemoryAllocator
77# define OGDF_ALLOCATOR ogdf::PoolMemoryAllocator
85#define OGDF_NEW_DELETE OGDF_MM(OGDF_ALLOCATOR)
92#define OGDF_MALLOC_NEW_DELETE OGDF_MM(ogdf::MallocMemoryAllocator)
118 const size_t s = n *
sizeof(T);
120 return static_cast<T*
>(OGDF_ALLOCATOR::allocate(s));
128 const size_t s = n *
sizeof(T);
130 OGDF_ALLOCATOR::deallocate(s, p);
Declaration of memory manager for allocating small pieces of memory.
Declaration of memory manager for allocating small pieces of memory.
Basic declarations, included by all source files.
static void * allocate(size_t nBytes, const char *, int)
Allocates memory of size nBytes.
static void deallocate(size_t, void *p)
Deallocates memory at address p. We do not keep track of the size of the deallocated object.
#define OGDF_LIKELY(x)
Specify the likely branch in a condition.
The namespace for all OGDF objects.
Encapsulates OGDF_ALLOCATOR in a class that can be used as the Allocator for containers of the C++ st...
T * allocate(const size_t n) const
void deallocate(T *const p, size_t n) const noexcept
bool operator==(const OGDFAllocator< U > &) const noexcept
OGDFAllocator() noexcept=default
bool operator!=(const OGDFAllocator< U > &) const noexcept