This class is used to allocate and free small objects (usually not polymorphic).
More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/util/SmallObjectAllocator.h>
|
struct | Chunk |
| The memory chunk is at the same time an element of a single linked list. More...
|
|
This class is used to allocate and free small objects (usually not polymorphic).
SmallObjectAllocator provides a fast alternative to new and delete for small objects.
- See also
- See this description for more information and an example.
orxonox::SmallObjectAllocator::SmallObjectAllocator |
( |
size_t |
objectSize, |
|
|
size_t |
numObjects = 64 |
|
) |
| |
Constructor: initializes the allocator and its values.
- Parameters
-
objectSize | The size in bytes (returned by sizeof()) of the allocated objects |
numObjects | The number of objects that are allocated in one block of memory |
orxonox::SmallObjectAllocator::~SmallObjectAllocator |
( |
| ) |
|
Destructor: deletes the allocated memory blocks.
void * orxonox::SmallObjectAllocator::alloc |
( |
| ) |
|
Returns the first free memory chunk or allocates a new block of memory.
void orxonox::SmallObjectAllocator::free |
( |
void * |
chunk | ) |
|
Puts the memory chunk back on the list of free memory.
void * orxonox::SmallObjectAllocator::getNext |
( |
void * |
chunk | ) |
|
|
staticprivate |
Helper function, returns the next_ pointer of a Chunk.
void orxonox::SmallObjectAllocator::setNext |
( |
void * |
chunk, |
|
|
void * |
next |
|
) |
| |
|
staticprivate |
Helper function, used to set the next_ pointer of a Chunk.
std::vector<char*> orxonox::SmallObjectAllocator::blocks_ |
|
private |
A list of all allocated memory blocks (used to destroy them again)
size_t orxonox::SmallObjectAllocator::chunkSize_ |
|
private |
The size of each chunk (and usually also the size of the created objects)
void* orxonox::SmallObjectAllocator::first_ |
|
private |
A pointer to the first free memory chunk.
size_t orxonox::SmallObjectAllocator::numChunksPerBlock_ |
|
private |
The number of chunks per memory block.
The documentation for this class was generated from the following files: