description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: cache_freelist Class | cache_freelist Class | 11/04/2016 |
|
| 840694de-36ba-470f-8dae-2b723d5a8cd9 |
Defines a block allocator that allocates and deallocates memory blocks of a single size.
template <std::size_t Sz, classMax> classcache_freelist
Sz
The number of elements in the array to be allocated.
Max
The max class representing the maximum size of the free list. This can be max_fixed_size, max_none, max_unbounded, or max_variable_size.
The cache_freelist class template maintains a free list of memory blocks of size Sz. When the free list is full it uses operator delete to deallocate memory blocks. When the free list is empty it uses operator new to allocate new memory blocks. The maximum size of the free list is determined by the class max class passed in the Max parameter.
Each memory block holds Sz bytes of usable memory and the data that operator new and operator delete require.
Constructor | Description |
---|---|
cache_freelist | Constructs an object of type cache_freelist . |
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_freelist
.
cache_freelist();
Frees a specified number of objects from storage beginning at a specified position.
voiddeallocate(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.