Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1
33#pragma once
34
37
38#include <new>
39
40namespace ogdf {
41
44
52#define OGDF_MM(Alloc) \
53public: \
54 static void* operator new(size_t nBytes) { \
55 if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
56 return Alloc::allocate(nBytes); \
57 else \
58 return ogdf::MallocMemoryAllocator::allocate(nBytes); \
59 } \
60 \
61 static void operator delete(void* p, size_t nBytes) { \
62 if (OGDF_LIKELY(p != 0)) { \
63 if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
64 Alloc::deallocate(nBytes, p); \
65 else \
66 ogdf::MallocMemoryAllocator::deallocate(nBytes, p); \
67 } \
68 } \
69 static void* operator new(size_t, void* p) { return p; } \
70 static void operator delete(void*, void*) { }
71
72#ifdef OGDF_MEMORY_MALLOC_TS
73# define OGDF_ALLOCATOR ogdf::MallocMemoryAllocator
74#else
76# define OGDF_ALLOCATOR ogdf::PoolMemoryAllocator
77#endif
78
84#define OGDF_NEW_DELETE OGDF_MM(OGDF_ALLOCATOR)
85
91#define OGDF_MALLOC_NEW_DELETE OGDF_MM(ogdf::MallocMemoryAllocator)
92
94
95}
Declaration of memory manager for allocating small pieces of memory.
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.