Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
MallocMemoryAllocator.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Logger.h>
37
38namespace ogdf {
39
42 struct MemElem {
44 };
45
47
48public:
50
52
53 static void cleanup() { }
54
56 static inline void* allocate(size_t nBytes, const char*, int) { return allocate(nBytes); }
57
59 static inline void* allocate(size_t nBytes) {
60 void* p = malloc(nBytes);
61 if (OGDF_UNLIKELY(p == nullptr)) {
63 }
64 return p;
65 }
66
69 static inline void deallocate(size_t, void* p) { free(p); }
70
72
75 static void deallocateList(size_t /* nBytes */, void* pHead, void* pTail) {
77 while (pHead != pStop) {
79 free(pHead);
80 pHead = q;
81 }
82 }
83
84 static void flushPool() { }
85
86 static void flushPool(uint16_t /* nBytes */) { }
87
89 static constexpr bool checkSize(size_t) { return true; }
90
92 static constexpr size_t memoryAllocatedInBlocks() { return 0; }
93
95 static constexpr size_t memoryInFreelist() { return 0; }
96
98 static constexpr size_t memoryInGlobalFreeList() { return 0; }
99
101 static constexpr size_t memoryInThreadFreeList() { return 0; }
102};
103
104}
Contains logging functionality.
Exception thrown when not enough memory is available to execute an algorithm.
Definition exceptions.h:203
Implements a simple memory manager using malloc() and free().
static void * allocate(size_t nBytes, const char *, int)
Allocates memory of size nBytes.
static constexpr size_t memoryAllocatedInBlocks()
Always returns 0, since no blocks are allocated.
static constexpr size_t memoryInFreelist()
Always returns 0, since no blocks are allocated.
static constexpr size_t memoryInThreadFreeList()
Always returns 0, since no blocks are allocated.
static constexpr bool checkSize(size_t)
Always returns true since we simply trust malloc().
static constexpr size_t memoryInGlobalFreeList()
Always returns 0, since no blocks are allocated.
static void deallocate(size_t, void *p)
Deallocates memory at address p. We do not keep track of the size of the deallocated object.
static void deallocateList(size_t, void *pHead, void *pTail)
Deallocate a complete list starting at pHead and ending at pTail.
static void * allocate(size_t nBytes)
Allocates memory of size nBytes.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
Definition of exception classes.
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition exceptions.h:63
#define OGDF_UNLIKELY(x)
Specify the unlikely branch in a condition.
Definition config.h:150
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.