Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
memory.h File Reference

Declaration of memory manager for allocating small pieces of memory. More...

Go to the source code of this file.

Namespaces

namespace  ogdf
 The namespace for all OGDF objects.
 

Macros

Managing memory
#define OGDF_ALLOCATOR   ogdf::PoolMemoryAllocator
 The used memory manager.
 
#define OGDF_MALLOC_NEW_DELETE   OGDF_MM(ogdf::MallocMemoryAllocator)
 Makes the class use malloc for memory allocation.
 
#define OGDF_MM(Alloc)
 Creates new and delete operators in a class using the given memory allocator.
 
#define OGDF_NEW_DELETE   OGDF_MM(OGDF_ALLOCATOR)
 Makes the class use OGDF's memory allocator.
 

Detailed Description

Declaration of memory manager for allocating small pieces of memory.

Author
Carsten Gutwenger
License:
This file is part of the Open Graph Drawing Framework (OGDF).
Copyright (C)
See README.md in the OGDF root directory for details.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 or 3 as published by the Free Software Foundation; see the file LICENSE.txt included in the packaging of this file for details.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/copyleft/gpl.html

Definition in file memory.h.

Macro Definition Documentation

◆ OGDF_ALLOCATOR

#define OGDF_ALLOCATOR   ogdf::PoolMemoryAllocator

The used memory manager.

Definition at line 76 of file memory.h.

◆ OGDF_MM

#define OGDF_MM (   Alloc)
Value:
public: \
static void* operator new(size_t nBytes) { \
if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
return Alloc::allocate(nBytes); \
} \
\
static void operator delete(void* p, size_t nBytes) { \
if (OGDF_LIKELY(p != 0)) { \
if (OGDF_LIKELY(Alloc::checkSize(nBytes))) \
Alloc::deallocate(nBytes, p); \
else \
ogdf::MallocMemoryAllocator::deallocate(nBytes, p); \
} \
} \
static void* operator new(size_t, void* p) { return p; } \
static void operator delete(void*, void*) { }
static void * allocate(size_t nBytes, const char *, int)
Allocates memory of size nBytes.
#define OGDF_LIKELY(x)
Specify the likely branch in a condition.
Definition config.h:143
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()

Creates new and delete operators in a class using the given memory allocator.

In other words, adding this macro in a class declaration makes that class managed by the respective memory manager. Throws an ogdf::InsufficientMemoryException if no more memory is available.

Definition at line 52 of file memory.h.