Skip to content

Latest commit

 

History

History
123 lines (93 loc) · 3.4 KB

File metadata and controls

123 lines (93 loc) · 3.4 KB
title cache_freelist Class | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-standard-libraries
ms.tgt_pltfrm
ms.topic article
f1_keywords
allocators/stdext::cache_freelist
stdext::cache_freelist
cache_freelist
allocators/stdext::cache_freelist::allocate
allocators/stdext::cache_freelist::deallocate
dev_langs
C++
helpviewer_keywords
cache_freelist class
ms.assetid 840694de-36ba-470f-8dae-2b723d5a8cd9
caps.latest.revision 19
author corob-msft
ms.author corob
manager ghogen
translation.priority.mt
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

cache_freelist Class

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

Syntax

template <std::size_t Sz, class Max>  
class cache_freelist

Parameters

Parameter Description
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.

Remarks

The cache_freelist template class 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.

Constructors

cache_freelist Constructs an object of type cache_freelist.

Member Functions

allocate Allocates a block of memory.
deallocate Frees a specified number of objects from storage beginning at a specified position.

Requirements

Header: <allocators>

Namespace: stdext

cache_freelist::allocate

Allocates a block of memory.

void *allocate(std::size_t count);

Parameters

Parameter Description
count The number of elements in the array to be allocated.

Return Value

A pointer to the allocated object.

Remarks

cache_freelist::cache_freelist

Constructs an object of type cache_freelist.

cache_freelist();

Remarks

cache_freelist::deallocate

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

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

Parameters

Parameter Description
ptr A pointer to the first object to be deallocated from storage.
count The number of objects to be deallocated from storage.

Remarks

See Also

<allocators>