|
CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
|
#include <nanoflann.hpp>
Public Member Functions | |
| PooledAllocator () | |
| ~PooledAllocator () | |
| void | free_all () |
| void * | malloc (const size_t req_size) |
| template<typename T> | |
| T * | allocate (const size_t count=1) |
Data Fields | |
| Size | usedMemory = 0 |
| Size | wastedMemory = 0 |
Private Types | |
| using | Size = size_t |
Private Member Functions | |
| void | internal_init () |
Private Attributes | |
| Size | remaining_ = 0 |
| Number of bytes left in current block of storage. | |
| void * | base_ = nullptr |
| Pointer to base of current block of storage. | |
| void * | loc_ = nullptr |
| Current location in block to next allocate. | |
Static Private Attributes | |
| static constexpr size_t | WORDSIZE = 16 |
| static constexpr size_t | BLOCKSIZE = 8192 |
Pooled storage allocator
The following routines allow for the efficient allocation of storage in small chunks from a specified pool. Rather than allowing each structure to be freed individually, an entire pool of storage is freed at once. This method has two advantages over just using malloc() and free(). First, it is far more efficient for allocating small objects, as there is no overhead for remembering all the information needed to free each object or consolidating fragmented memory. Second, the decision about how long to keep an object is made at the time of allocation, and there is no need to track down all the objects to free them.
Definition at line 859 of file nanoflann.hpp.
|
private |
Definition at line 870 of file nanoflann.hpp.
|
inline |
Default constructor. Initializes a new pool.
Definition at line 891 of file nanoflann.hpp.
|
inline |
Destructor. Frees all the memory allocated in this pool.
Definition at line 896 of file nanoflann.hpp.
|
inline |
Allocates (using this pool) a generic type T.
Params: count = number of instances to allocate. Returns: pointer (of type T*) to memory buffer
Definition at line 965 of file nanoflann.hpp.
|
inline |
Frees all allocated memory chunks
Definition at line 899 of file nanoflann.hpp.
Referenced by ~PooledAllocator().
|
inlineprivate |
Definition at line 876 of file nanoflann.hpp.
Referenced by free_all(), and PooledAllocator().
|
inline |
Returns a pointer to a piece of new memory of the given size in bytes allocated from the pool.
Definition at line 915 of file nanoflann.hpp.
Referenced by allocate(), and malloc().
|
private |
Pointer to base of current block of storage.
Definition at line 873 of file nanoflann.hpp.
Referenced by free_all(), internal_init(), and malloc().
|
staticconstexprprivate |
Definition at line 862 of file nanoflann.hpp.
Referenced by malloc().
|
private |
Current location in block to next allocate.
Definition at line 874 of file nanoflann.hpp.
Referenced by malloc().
|
private |
Number of bytes left in current block of storage.
Definition at line 872 of file nanoflann.hpp.
Referenced by internal_init(), and malloc().
| Size nanoflann::PooledAllocator::usedMemory = 0 |
Definition at line 885 of file nanoflann.hpp.
Referenced by internal_init(), and malloc().
| Size nanoflann::PooledAllocator::wastedMemory = 0 |
Definition at line 886 of file nanoflann.hpp.
Referenced by internal_init(), and malloc().
|
staticconstexprprivate |
Definition at line 861 of file nanoflann.hpp.
Referenced by malloc().