![]() |
ATLAS Offline Software
|
Very simple allocator for use with pointer_list
.
More...
#include <pointer_list.h>
Classes | |
struct | chunk |
One memory allocation chunk. More... | |
Public Member Functions | |
allocator (size_t nelt, size_t nblock, unsigned long end_mask, unsigned long end_offs) | |
Constructor. More... | |
~allocator () | |
Destructor. Deletes all blocks from this allocator. More... | |
list_block * | allocate () |
Allocate a new block. More... | |
size_t | nelt () const |
Return the number of pointers per block (excluding the end-pointer). More... | |
size_t | nchunks () const |
Return the current number of allocated chunks. More... | |
bool | at_end (const void *p) const |
Test if P is pointing at the end-pointer of a block. More... | |
Private Member Functions | |
void | refill () |
Allocate a new chunk of blocks. More... | |
Private Attributes | |
size_t | m_nelt |
Number of elements per block (excluding the end-pointer). More... | |
size_t | m_nblock |
Number of blocks per chunk. More... | |
chunk * | m_chunks |
Most recent chunk allocated. More... | |
size_t | m_nthis |
Number of blocks allocated so far from that chunk. More... | |
size_t | m_nchunks |
Current number of allocated chunks. More... | |
unsigned long | m_end_mask |
Mask for testing for an end pointer. More... | |
unsigned long | m_end_offs |
Offset for testing for an end pointer. More... | |
Very simple allocator for use with pointer_list
.
We allocate large chunks and divide them up into list_block's
. We don't support deleting individual elements; instead, everything is deleted when the allocator is. The chunks are chained together to allow for this.
The total size of a block should be a power of two, and blocks must be aligned to this boundary.
Definition at line 94 of file pointer_list.h.
CxxUtils::pointer_list_base::allocator::allocator | ( | size_t | nelt, |
size_t | nblock, | ||
unsigned long | end_mask, | ||
unsigned long | end_offs | ||
) |
Constructor.
nelt | Number of pointers per block (excluding the end pointer). Must be one less than a power of two. |
nblock | Number of blocks to allocate per chunk. |
end_mask | Mask to use for end-of-block test. |
end_offs | Offset to use for end-of-block test. |
nelt | Number of pointers per block. (excluding the end pointer). |
nblock | Number of blocks to allocate per chunk. |
end_mask | Mask to use for end-of-block test. |
end_offs | Offset to use for end-of-block test. |
Definition at line 29 of file pointer_list.cxx.
CxxUtils::pointer_list_base::allocator::~allocator | ( | ) |
Destructor. Deletes all blocks from this allocator.
Destructor.
Deletes all blocks from this allocator.
Definition at line 47 of file pointer_list.cxx.
list_block* CxxUtils::pointer_list_base::allocator::allocate | ( | ) |
Allocate a new block.
bool CxxUtils::pointer_list_base::allocator::at_end | ( | const void * | p | ) | const |
Test if P is pointing at the end-pointer of a block.
size_t CxxUtils::pointer_list_base::allocator::nchunks | ( | ) | const |
Return the current number of allocated chunks.
size_t CxxUtils::pointer_list_base::allocator::nelt | ( | ) | const |
Return the number of pointers per block (excluding the end-pointer).
|
private |
|
private |
Most recent chunk allocated.
Definition at line 149 of file pointer_list.h.
|
private |
Mask for testing for an end pointer.
Definition at line 158 of file pointer_list.h.
|
private |
Offset for testing for an end pointer.
Definition at line 161 of file pointer_list.h.
|
private |
Number of blocks per chunk.
Definition at line 146 of file pointer_list.h.
|
private |
Current number of allocated chunks.
Definition at line 155 of file pointer_list.h.
|
private |
Number of elements per block (excluding the end-pointer).
Definition at line 143 of file pointer_list.h.
|
private |
Number of blocks allocated so far from that chunk.
Definition at line 152 of file pointer_list.h.