| description | Learn more about: cache_chunklist Class | |||
|---|---|---|---|---|
| title | cache_chunklist Class | |||
| ms.date | 11/04/2016 | |||
| f1_keywords |
|
|||
| helpviewer_keywords |
|
|||
| ms.assetid | af19eccc-4ae7-4a34-bbb2-81e397424cb9 |
Defines a block allocator that allocates and deallocates memory blocks of a single size.
template <std::size_t Sz, std::size_t Nelts = 20>
class cache_chunklistSz
The number of elements in the array to be allocated.
This class template uses operator new to allocate chunks of raw memory, suballocating blocks to allocate storage for a memory block when needed; it stores deallocated memory blocks in a separate free list for each chunk, and uses operator delete to deallocate a chunk when none of its memory blocks is in use.
Each memory block holds Sz bytes of usable memory and a pointer to the chunk that it belongs to. Each chunk holds Nelts memory blocks, three pointers, an int and the data that operator new and operator delete require.
| Constructor | Description |
|---|---|
| cache_chunklist | Constructs an object of type cache_chunklist. |
| Member function | Description |
|---|---|
| allocate | Allocates a block of memory. |
| deallocate | Frees 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);count
The number of elements in the array to be allocated.
A pointer to the allocated object.
Constructs an object of type cache_chunklist.
cache_chunklist();Frees a specified number of objects from storage beginning at a specified position.
void deallocate(void* ptr, std::size_t count);ptr
A pointer to the first object to be deallocated from storage.
count
The number of objects to be deallocated from storage.