cache_suballoc Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Defines a block allocator that allocates and deallocates memory blocks of a single size.

template <std::size_t Sz, size_t Nelts = 20>  
class cache_suballoc

Parameters

ParameterDescription
SzThe number of elements in the array to be allocated.

The cache_suballoc template class stores deallocated memory blocks in a free list with unbounded length, using freelist<sizeof(Type), max_unbounded>, and suballocates memory blocks from a larger chunk allocated with operator new when the free list is empty.

Each chunk holds Sz * Nelts bytes of usable memory and the data that operator new and operator delete require. Allocated chunks are never freed.

Constructors

cache_suballocConstructs an object of type cache_suballoc.

Member Functions

allocateAllocates a block of memory.
deallocateFrees a specified number of objects from storage beginning at a specified position.

Header: <allocators>

Namespace: stdext

Allocates a block of memory.

void *allocate(std::size_t count);

Parameters

ParameterDescription
countThe number of elements in the array to be allocated.

Return Value

A pointer to the allocated object.

Remarks

Constructs an object of type cache_suballoc.

cache_suballoc();

Remarks

Frees a specified number of objects from storage beginning at a specified position.

void deallocate(void* ptr, std::size_t count);

Parameters

ParameterDescription
ptrA pointer to the first object to be deallocated from storage.
countThe number of objects to be deallocated from storage.

Remarks

<allocators>

Show: