![]() |
Bitcoin Core 31.0.0
P2P Digital Currency
|
#include <lockedpool.h>
Classes | |
| struct | Stats |
| Memory statistics. More... | |
Public Member Functions | |
| Arena (void *base, size_t size, size_t alignment) | |
| virtual | ~Arena () |
| Arena (const Arena &other)=delete | |
| Arena & | operator= (const Arena &)=delete |
| void * | alloc (size_t size) |
| Allocate size bytes from this arena. | |
| void | free (void *ptr) |
| Free a previously allocated chunk of memory. | |
| Stats | stats () const |
| Get arena usage statistics. | |
| bool | addressInArena (void *ptr) const |
| Return whether a pointer points inside this arena. | |
Private Types | |
| typedef std::multimap< size_t, void * > | SizeToChunkSortedMap |
| typedef std::unordered_map< void *, SizeToChunkSortedMap::const_iterator > | ChunkToSizeMap |
Private Attributes | |
| SizeToChunkSortedMap | size_to_free_chunk |
| Map to enable O(log(n)) best-fit allocation, as it's sorted by size. | |
| ChunkToSizeMap | chunks_free |
| Map from begin of free chunk to its node in size_to_free_chunk. | |
| ChunkToSizeMap | chunks_free_end |
| Map from end of free chunk to its node in size_to_free_chunk. | |
| std::unordered_map< void *, size_t > | chunks_used |
| Map from begin of used chunk to its size. | |
| void * | base |
| Base address of arena. | |
| void * | end |
| End address of arena. | |
| size_t | alignment |
| Minimum chunk alignment. | |
Definition at line 48 of file lockedpool.h.
|
private |
Definition at line 96 of file lockedpool.h.
|
private |
Definition at line 92 of file lockedpool.h.
|
virtualdefault |
|
delete |
Return whether a pointer points inside this arena.
This returns base <= ptr < (base+size) so only use it for (inclusive) chunk starting addresses.
Definition at line 90 of file lockedpool.h.
Allocate size bytes from this arena.
Returns pointer on success, or 0 if memory is full or the application tried to allocate 0 bytes.
Definition at line 50 of file lockedpool.cpp.
Free a previously allocated chunk of memory.
Freeing the zero pointer has no effect. Raises std::runtime_error in case of error.
Definition at line 86 of file lockedpool.cpp.
| Arena::Stats Arena::stats | ( | ) | const |
Get arena usage statistics.
Definition at line 124 of file lockedpool.cpp.
|
private |
Minimum chunk alignment.
Definition at line 110 of file lockedpool.h.
|
private |
Base address of arena.
Definition at line 106 of file lockedpool.h.
|
private |
Map from begin of free chunk to its node in size_to_free_chunk.
Definition at line 98 of file lockedpool.h.
|
private |
Map from end of free chunk to its node in size_to_free_chunk.
Definition at line 100 of file lockedpool.h.
Map from begin of used chunk to its size.
Definition at line 103 of file lockedpool.h.
|
private |
End address of arena.
Definition at line 108 of file lockedpool.h.
|
private |
Map to enable O(log(n)) best-fit allocation, as it's sorted by size.
Definition at line 94 of file lockedpool.h.