Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

memory.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <new>
36 
39 
40 namespace ogdf {
41 
44 
52 #define OGDF_MM(Alloc) \
53 public: \
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
75 #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 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
MallocMemoryAllocator.h
Declaration of memory manager for allocating small pieces of memory.
PoolMemoryAllocator.h
Declaration of memory manager for allocating small pieces of memory.