lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
Classes | Public Types | Public Member Functions | Static Public Attributes
lean::memory::chunk_heap< ChunkSize, Heap, StaticChunkSize, DefaultAlignment > Class Template Reference

Contiguous chunk allocator heap. More...

#include <chunk_heap.h>

Inherits noncopyable.

List of all members.

Classes

struct  chunk_header
 Chunk header.

Public Types

typedef Heap heap_type
 Heap type.
typedef heap_type::size_type size_type
 Size type.

Public Member Functions

LEAN_INLINE chunk_heap (size_type chunkSize=ChunkSize)
 Constructor.
LEAN_INLINE ~chunk_heap ()
 Destructor.
LEAN_INLINE void nextChunkSize (size_type nextSize)
 Sets the next chunk size.
LEAN_INLINE size_type nextChunkSize () const
 Gets the next chunk size.
LEAN_INLINE size_type capacity () const
 Gets the remaining capacity of the current chunk.
LEAN_INLINE void reserve (size_type newCapacity, size_type minChunkSize=chunk_size)
 Tweaks the next chunk size to fit at least the given amount of objects about to be allocated. Passing 0 for.
void clear ()
 Clears and frees all chunks allocated by this allocator.
void clearButFirst ()
 Clears all chunks and frees all chunks but the first one dynamically allocated by this allocator if it has not been exhausted yet.
bool currentStatic ()
 Gets whether the current chunk is static.
char * currentOffset ()
 Gets the current chunk offset.
char * clearCurrent ()
 Clears the current chunk but frees none.
char * clearFreeNext ()
 Clears all chunks and frees the current chunk, returning the next.
LEAN_INLINE void * allocate (size_type size)
 Allocates the given amount of memory.
LEAN_INLINE void free (void *memory)
 Frees the given block of memory.
template<size_t Alignment>
LEAN_INLINE void * allocate (size_type size)
 Allocates the given amount of memory respecting the given alignment.
template<size_t Alignment>
LEAN_INLINE void free (void *memory)
 Frees the given aligned block of memory.

Static Public Attributes

static const size_type chunk_size = ChunkSize
 Chunk size.
static const size_type default_alignment = DefaultAlignment
 Default alignment.

Detailed Description

template<size_t ChunkSize, class Heap = default_heap, size_t StaticChunkSize = ChunkSize, size_t DefaultAlignment = sizeof(void*)>
class lean::memory::chunk_heap< ChunkSize, Heap, StaticChunkSize, DefaultAlignment >

Contiguous chunk allocator heap.


Member Function Documentation

template<size_t ChunkSize, class Heap = default_heap, size_t StaticChunkSize = ChunkSize, size_t DefaultAlignment = sizeof(void*)>
LEAN_INLINE void lean::memory::chunk_heap< ChunkSize, Heap, StaticChunkSize, DefaultAlignment >::reserve ( size_type  newCapacity,
size_type  minChunkSize = chunk_size 
) [inline]

Tweaks the next chunk size to fit at least the given amount of objects about to be allocated. Passing 0 for.

 minChunkSize

will result in an exact fit of the given amount of objects. WARNING: When passing 0 for an exact fit, either call

after you're done allocating or recall

for sensible reallocation behavior in subsequent bulk allocations.


The documentation for this class was generated from the following file: