ug4
SmallObjectAllocator< maxObjSize, maxChunkSize > Class Template Reference

#include <small_object_allocator.h>

Public Member Functions

void * allocate (std::size_t numBytes)
 if numBytes > maxObjSize, allocate will directly call new. More...
 
void deallocate (void *p, std::size_t size)
 make sure that size exactly specifies the number of bytes of the object to which p points. More...
 

Static Public Member Functions

static SmallObjectAllocatorinst ()
 returns an instance to this singleton More...
 

Private Member Functions

 SmallObjectAllocator ()
 

Private Attributes

std::vector< FixedAllocatorm_allocators
 

Detailed Description

template<std::size_t maxObjSize = 64, std::size_t maxChunkSize = 4096>
class SmallObjectAllocator< maxObjSize, maxChunkSize >

A singleton that can be used to allocate small objects.

Constructor & Destructor Documentation

◆ SmallObjectAllocator()

template<std::size_t maxObjSize, std::size_t maxChunkSize>
SmallObjectAllocator< maxObjSize, maxChunkSize >::SmallObjectAllocator
private

Member Function Documentation

◆ allocate()

template<std::size_t maxObjSize, std::size_t maxChunkSize>
void * SmallObjectAllocator< maxObjSize, maxChunkSize >::allocate ( std::size_t  numBytes)

if numBytes > maxObjSize, allocate will directly call new.

Referenced by SmallObject< maxObjSize, maxChunkSize >::operator new().

◆ deallocate()

template<std::size_t maxObjSize, std::size_t maxChunkSize>
void SmallObjectAllocator< maxObjSize, maxChunkSize >::deallocate ( void *  p,
std::size_t  size 
)

make sure that size exactly specifies the number of bytes of the object to which p points.

References p.

Referenced by SmallObject< maxObjSize, maxChunkSize >::operator delete().

◆ inst()

template<std::size_t maxObjSize, std::size_t maxChunkSize>
SmallObjectAllocator< maxObjSize, maxChunkSize > & SmallObjectAllocator< maxObjSize, maxChunkSize >::inst
static

Member Data Documentation

◆ m_allocators

template<std::size_t maxObjSize = 64, std::size_t maxChunkSize = 4096>
std::vector<FixedAllocator> SmallObjectAllocator< maxObjSize, maxChunkSize >::m_allocators
private

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